modules/enterprise/server/jar/pom.xml
| 4 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java
| 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertDefinitionRest.java
| 8 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertRest.java
| 13 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AvailabilityRest.java
| 8 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Baseline.java
| 8 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventRest.java
| 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventSourceRest.java
| 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupDefinitionRest.java
| 11 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupRest.java
| 12 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Link.java
| 6 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricAggregate.java
| 13 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricSchedule.java
| 14 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/NumericDataPoint.java
| 7 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationDefinitionRest.java
| 7 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationHistoryRest.java
| 10 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationRest.java
| 14 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithChildren.java
| 7 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithType.java
| 15 +++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/SimplePropDef.java
| 9 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Status.java
| 5 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/StringValue.java
| 5 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/UserRest.java
| 10 ++
modules/enterprise/server/plugins/alert-sms/src/main/java/org/rhq/enterprise/server/plugins/alertSms/SmsSender.java
| 35 +++++-----
modules/helpers/rest-docs-generator/pom.xml
| 2
modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
| 15 +++-
26 files changed, 219 insertions(+), 27 deletions(-)
New commits:
commit aba99ed81d4645a1034ed38dea51a02c6d671e98
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Oct 24 15:15:32 2012 +0200
Document the data classes of the REST api.
diff --git a/modules/enterprise/server/jar/pom.xml
b/modules/enterprise/server/jar/pom.xml
index dbcaac4..896a352 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -517,7 +517,7 @@
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations_2.9.1</artifactId>
- <version>1.1-SNAPSHOT</version>
+ <version>1.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.rhq.helpers</groupId>
@@ -925,7 +925,7 @@
<field>namespace</field>
<justification>The namespace changes with every version, so this
is definitely an intentional change.</justification>
</difference>
- </ignored>
+ </ignored>
</configuration>
</plugin>
</plugins>
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java
index e6f9335..f3bcdff 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java
@@ -249,7 +249,7 @@ public class GroupHandlerBean extends AbstractRestBean implements
GroupHandlerLo
List<MetricSchedule> schedules = new
ArrayList<MetricSchedule>(definitions.size());
for (MeasurementDefinition def : definitions) {
MetricSchedule schedule = new
MetricSchedule(def.getId(),def.getName(),def.getDisplayName(),false,def.getDefaultInterval(),
- def.getUnits().getName(),def.getDisplayType().toString());
+ def.getUnits().getName(),def.getDataType().toString());
if (def.getDataType()== DataType.MEASUREMENT) {
UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
uriBuilder.path("/metric/data/group/{groupId}/{definitionId}");
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertDefinitionRest.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertDefinitionRest.java
index 0719d4a..c7cf98b 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertDefinitionRest.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertDefinitionRest.java
@@ -20,11 +20,14 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
/**
* Alert Definition
* @author Heiko W. Rupp
*/
+@ApiClass("Representation of an AlertDefinition")
@XmlRootElement
public class AlertDefinitionRest {
@@ -41,6 +44,7 @@ public class AlertDefinitionRest {
this.id = id;
}
+ @ApiProperty("The id of the definition")
public int getId() {
return id;
}
@@ -49,6 +53,7 @@ public class AlertDefinitionRest {
this.id = id;
}
+ @ApiProperty("The name of the definition")
public String getName() {
return name;
}
@@ -57,6 +62,7 @@ public class AlertDefinitionRest {
this.name = name;
}
+ @ApiProperty("Is the definition enabled(=active)?")
public boolean isEnabled() {
return enabled;
}
@@ -65,6 +71,8 @@ public class AlertDefinitionRest {
this.enabled = enabled;
}
+ @ApiProperty(value = "The priority of the definition",
+ allowableValues = "LOW, MEDIUM, HIGH")
public String getPriority() {
return priority;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertRest.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertRest.java
index d09f5b8..db44a3b 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertRest.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertRest.java
@@ -24,12 +24,16 @@ import java.util.List;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
import org.jboss.resteasy.links.RESTServiceDiscovery;
/**
* A single alert
* @author Heiko W. Rupp
*/
+@ApiClass(value = "This class represents a single fired alert.")
@XmlRootElement
public class AlertRest {
@@ -61,18 +65,22 @@ public class AlertRest {
this.alertDefinition = alertDefinitionId;
}
+ @ApiProperty("The id of the alert")
public int getId() {
return id;
}
+ @ApiProperty("Name of the alert, taken from the AlertDefinition")
public String getName() {
return name;
}
+ @ApiProperty("AlertDefinition from which the alert was fired")
public AlertDefinitionRest getAlertDefinition() {
return alertDefinition;
}
+ @ApiProperty("Is the definition enabled (=active)?")
public boolean isDefinitionEnabled() {
return definitionEnabled;
}
@@ -81,6 +89,7 @@ public class AlertRest {
this.definitionEnabled = definitionEnabled;
}
+ @ApiProperty("The user that acknowledged the alert (if any)")
public String getAckBy() {
return ackBy;
}
@@ -89,6 +98,7 @@ public class AlertRest {
this.ackBy = ackBy;
}
+ @ApiProperty("Timestamp of the acknowledgement")
public long getAckTime() {
return ackTime;
}
@@ -97,6 +107,7 @@ public class AlertRest {
this.ackTime = ackTime;
}
+ @ApiProperty("Timestamp when the alert has been fired")
public long getAlertTime() {
return alertTime;
}
@@ -105,6 +116,7 @@ public class AlertRest {
this.alertTime = alertTime;
}
+ @ApiProperty("Description of the alert")
public String getDescription() {
return description;
}
@@ -113,6 +125,7 @@ public class AlertRest {
this.description = description;
}
+ @ApiProperty("The resource on which the alert was fired")
public ResourceWithType getResource() {
return resource;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AvailabilityRest.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AvailabilityRest.java
index 2710660..991f0e4 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AvailabilityRest.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AvailabilityRest.java
@@ -22,6 +22,9 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
import org.jboss.resteasy.links.RESTServiceDiscovery;
import org.rhq.core.domain.measurement.AvailabilityType;
@@ -30,6 +33,7 @@ import org.rhq.core.domain.measurement.AvailabilityType;
* Availability implementation for exposing via REST
* @author Heiko W. Rupp
*/
+@ApiClass("Represents the availability of a resource")
@XmlRootElement(name = "availability")
public class AvailabilityRest {
@@ -55,16 +59,19 @@ public class AvailabilityRest {
this.resourceId = resourceId;
}
+ @ApiProperty("Time since the type is valid")
@XmlElement
public long getSince() {
return since;
}
+ @ApiProperty(value = "Type of availability", allowableValues = "UP,
DOWN, DISABLED, UNKNOWN")
@XmlElement
public String getType() {
return type;
}
+ @ApiProperty("Id of the resource that reports the availability")
@XmlElement
public int getResourceId() {
return resourceId;
@@ -82,6 +89,7 @@ public class AvailabilityRest {
this.resourceId = resourceId;
}
+ @ApiProperty("Time until the type is valid. May be null if type is
ongoing")
public Long getUntil() {
return until;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Baseline.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Baseline.java
index d6a4073..69623fb 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Baseline.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Baseline.java
@@ -2,10 +2,14 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* A baseline
* @author Heiko W. Rupp
*/
+@ApiClass("Representation of a metic baseline/-band")
@XmlRootElement
public class Baseline {
@@ -24,6 +28,7 @@ public class Baseline {
this.computeTime = computeTime;
}
+ @ApiProperty("The lower value of the base band")
public double getMin() {
return min;
}
@@ -32,6 +37,7 @@ public class Baseline {
this.min = min;
}
+ @ApiProperty("The higher value of the base band")
public double getMax() {
return max;
}
@@ -40,6 +46,7 @@ public class Baseline {
this.max = max;
}
+ @ApiProperty("The baseline value (i.e. the average of the metrics")
public double getMean() {
return mean;
}
@@ -48,6 +55,7 @@ public class Baseline {
this.mean = mean;
}
+ @ApiProperty("Time this value was computed")
public long getComputeTime() {
return computeTime;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventRest.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventRest.java
index 666b0dc..5657e3c 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventRest.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventRest.java
@@ -22,13 +22,14 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlRootElement;
import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiClass;
import com.wordnik.swagger.annotations.ApiProperty;
/**
* An event
* @author Heiko W. Rupp
*/
-@Api("This class represents one event.")
+@ApiClass("This class represents one event.")
@XmlRootElement(name = "event")
public class EventRest {
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventSourceRest.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventSourceRest.java
index 5cfa3c9..6d121b9 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventSourceRest.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/EventSourceRest.java
@@ -22,13 +22,14 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlRootElement;
import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiClass;
import com.wordnik.swagger.annotations.ApiProperty;
/**
* An EventSource
* @author Heiko W. Rupp
*/
-@Api("This class represents an EventSource - e.g. a logfile.")
+@ApiClass("This class represents an EventSource - e.g. a logfile.")
@XmlRootElement(name="source")
public class EventSourceRest {
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupDefinitionRest.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupDefinitionRest.java
index 93b715c..65573a7 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupDefinitionRest.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupDefinitionRest.java
@@ -25,10 +25,14 @@ import java.util.List;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* A group definition ("Dyna Group definition")
* @author Heiko W. Rupp
*/
+@ApiClass("One DynaGroup definition")
@XmlRootElement(name="groupDefinition")
public class GroupDefinitionRest {
@@ -51,6 +55,7 @@ public class GroupDefinitionRest {
this.recalcInterval = recalcInterval;
}
+ @ApiProperty("The id of the definition")
public int getId() {
return id;
}
@@ -59,6 +64,7 @@ public class GroupDefinitionRest {
this.id = id;
}
+ @ApiProperty("The name of the definition")
public String getName() {
return name;
}
@@ -67,6 +73,7 @@ public class GroupDefinitionRest {
this.name = name;
}
+ @ApiProperty("A description of the definition")
public String getDescription() {
return description;
}
@@ -75,6 +82,7 @@ public class GroupDefinitionRest {
this.description = description;
}
+ @ApiProperty("Individual lines of the group expression")
public List<String> getExpression() {
return expression;
}
@@ -83,6 +91,7 @@ public class GroupDefinitionRest {
this.expression = expression;
}
+ @ApiProperty("Interval in ms at which the expression should be
re-evaluated")
public long getRecalcInterval() {
return recalcInterval;
}
@@ -91,6 +100,7 @@ public class GroupDefinitionRest {
this.recalcInterval = recalcInterval;
}
+ @ApiProperty("List of ids for the groups generated by this group
expression")
public List<Integer> getGeneratedGroupIds() {
return generatedGroupIds;
}
@@ -99,6 +109,7 @@ public class GroupDefinitionRest {
this.generatedGroupIds = generatedGroupIds;
}
+ @ApiProperty("Is this definition generating rescursive groups?")
public boolean isRecursive() {
return recursive;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupRest.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupRest.java
index c43f911..e0f32e7 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupRest.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupRest.java
@@ -6,12 +6,16 @@ import java.util.List;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
import org.rhq.core.domain.resource.group.GroupCategory;
/**
* Representation of a resource group
* @author Heiko W. Rupp
*/
+@ApiClass("Representation of a resource group")
@XmlRootElement
public class GroupRest {
@@ -34,6 +38,7 @@ public class GroupRest {
this.name = name;
}
+ @ApiProperty("Id of the group")
public int getId() {
return id;
}
@@ -42,6 +47,7 @@ public class GroupRest {
this.id = id;
}
+ @ApiProperty("Name of the group")
public String getName() {
return name;
}
@@ -50,6 +56,7 @@ public class GroupRest {
this.name = name;
}
+ @ApiProperty("ResourceType id for compatible groups")
public Integer getResourceTypeId() {
return resourceTypeId;
}
@@ -58,6 +65,7 @@ public class GroupRest {
this.resourceTypeId = resourceTypeId;
}
+ @ApiProperty("True if the group is recursive (i.e. includes child
resources")
public boolean isRecursive() {
return recursive;
}
@@ -66,6 +74,7 @@ public class GroupRest {
this.recursive = recursive;
}
+ @ApiProperty(value="Category of the group. ", allowableValues =
"COMPATIBLE, MIXED" )
public GroupCategory getCategory() {
return category;
}
@@ -83,6 +92,7 @@ public class GroupRest {
this.links = links;
}
+ @ApiProperty("Id of a DynaGroup definition if the group was defined by a
DynaGroup.")
public int getDynaGroupDefinitionId() {
return dynaGroupDefinitionId;
}
@@ -91,6 +101,7 @@ public class GroupRest {
this.dynaGroupDefinitionId = dynaGroupDefinitionId;
}
+ @ApiProperty("Number of explicitly added resources in the group")
public int getExplicitCount() {
return explicitCount;
}
@@ -99,6 +110,7 @@ public class GroupRest {
this.explicitCount = explicitCount;
}
+ @ApiProperty("Number of resources in the group (explict + children for a
recursive group")
public int getImplicitCount() {
return implicitCount;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Link.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Link.java
index 1936425..3287750 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Link.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Link.java
@@ -3,10 +3,14 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* A link between two resources
* @author Heiko W. Rupp
*/
+@ApiClass("Link between two resources")
@XmlRootElement
public class Link {
@@ -22,11 +26,13 @@ public class Link {
}
+ @ApiProperty("Name of the relation")
@XmlAttribute
public String getRel() {
return rel;
}
+ @ApiProperty("Target of the relation")
@XmlAttribute
public String getHref() {
return href;
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricAggregate.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricAggregate.java
index 46605cf..7ad1e50 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricAggregate.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricAggregate.java
@@ -24,10 +24,14 @@ import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* Metric data that could be used to draw a chart
* @author Heiko W. Rupp
*/
+@ApiClass("An aggregate of metrics data for a given schedule")
@XmlRootElement
public class MetricAggregate {
@@ -55,6 +59,7 @@ public class MetricAggregate {
}
+ @ApiProperty("List of indiviudual data points")
@XmlElement
public List<DataPoint> getDataPoints() {
return dataPoints;
@@ -68,16 +73,19 @@ public class MetricAggregate {
this.dataPoints = dataPoints;
}
+ @ApiProperty("Minimum value for the data")
@XmlElement
public Double getMin() {
return min;
}
+ @ApiProperty("Average value for the data")
@XmlElement
public Double getAvg() {
return avg;
}
+ @ApiProperty("Maximum value for the data")
@XmlElement
public Double getMax() {
return max;
@@ -95,6 +103,7 @@ public class MetricAggregate {
this.max = max;
}
+ @ApiProperty("Number of data points i.e. size of the dataPoints list")
public int getNumDataPoints() {
return numDataPoints;
}
@@ -103,6 +112,7 @@ public class MetricAggregate {
this.numDataPoints = numDataPoints;
}
+ @ApiProperty("Id of the metric")
@XmlElement
public Integer getScheduleId() {
return scheduleId;
@@ -112,6 +122,7 @@ public class MetricAggregate {
this.scheduleId = scheduleId;
}
+ @ApiProperty("Timestamp of the earliest data point in the list")
public long getMinTimeStamp() {
return minTimeStamp;
}
@@ -120,6 +131,7 @@ public class MetricAggregate {
this.minTimeStamp = minTimeStamp;
}
+ @ApiProperty("Timestamp fo the latest data point in the list")
public long getMaxTimeStamp() {
return maxTimeStamp;
}
@@ -128,6 +140,7 @@ public class MetricAggregate {
this.maxTimeStamp = maxTimeStamp;
}
+ @ApiProperty("Determines if this is data for a group")
public boolean isGroup() {
return isGroup;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricSchedule.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricSchedule.java
index 30a006b..cd12b04 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricSchedule.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/MetricSchedule.java
@@ -27,12 +27,17 @@ import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
import org.jboss.resteasy.spi.touri.URITemplate;
/**
* A simple metric schedule
* @author Heiko W. Rupp
*/
+@ApiClass(value = "A single metrics schedule",
+ description = "A scheudle represents the collection interval for a metric and if
the collection is enabled")
@XmlRootElement
@URITemplate("/metric/schedule/{id}")
public class MetricSchedule {
@@ -61,6 +66,7 @@ public class MetricSchedule {
this.type = type;
}
+ @ApiProperty("The id of the schedule")
@XmlID
public String getScheduleId() {
return ""+scheduleId;
@@ -70,6 +76,7 @@ public class MetricSchedule {
this.scheduleId = scheduleId;
}
+ @ApiProperty("The name of the metric")
public String getScheduleName() {
return scheduleName;
}
@@ -78,6 +85,7 @@ public class MetricSchedule {
this.scheduleName = scheduleName;
}
+ @ApiProperty("Is the collection enabled?")
public Boolean getEnabled() {
return enabled;
}
@@ -86,6 +94,8 @@ public class MetricSchedule {
this.enabled = enabled;
}
+ @ApiProperty(value = "The collection interval in milliseconds",
+ allowableValues = "A minimum of 30s")
public long getCollectionInterval() {
return collectionInterval;
}
@@ -94,6 +104,7 @@ public class MetricSchedule {
this.collectionInterval = collectionInterval;
}
+ @ApiProperty("The name of the metric as shown in the UI")
public String getDisplayName() {
return displayName;
}
@@ -102,6 +113,7 @@ public class MetricSchedule {
this.displayName = displayName;
}
+ @ApiProperty("The base unit of the metric")
public String getUnit() {
return unit;
}
@@ -110,6 +122,7 @@ public class MetricSchedule {
this.unit = unit;
}
+ @ApiProperty(value ="Type of metric", allowableValues = "MEASUREMENT,
TRAIT, COMPLEX, CALLTIME, AVAILABILITY")
public String getType() {
return type;
}
@@ -122,6 +135,7 @@ public class MetricSchedule {
// return String.valueOf(enabled);
// }
+ @ApiProperty("Last modification timestamp of the schedule")
@XmlTransient
public long getMtime() {
return mtime;
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/NumericDataPoint.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/NumericDataPoint.java
index e1ef904..4223fe7 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/NumericDataPoint.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/NumericDataPoint.java
@@ -3,6 +3,9 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* One numerical data point of a schedule.
* This point does not contain the schedule id, as it is expected
@@ -13,6 +16,7 @@ import javax.xml.bind.annotation.XmlRootElement;
*
* @author Heiko W. Rupp
*/
+@ApiClass("One numerical data point of a metric (aka schedule)")
@XmlRootElement
public class NumericDataPoint {
@@ -36,16 +40,19 @@ public class NumericDataPoint {
this.value = value;
}
+ @ApiProperty("The timestamp when the metric was taken")
@XmlAttribute
public long getTimeStamp() {
return timeStamp;
}
+ @ApiProperty("The numerical value")
@XmlAttribute
public Double getValue() {
return value;
}
+ @ApiProperty("The id of the metric")
@XmlAttribute
public int getScheduleId() {
return scheduleId;
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationDefinitionRest.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationDefinitionRest.java
index 06cbbcf..2f5055c 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationDefinitionRest.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationDefinitionRest.java
@@ -8,9 +8,13 @@ import java.util.Map;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* @author Heiko W. Rupp
*/
+@ApiClass(value = "The template from which operations are created")
@XmlRootElement
public class OperationDefinitionRest {
@@ -22,6 +26,7 @@ public class OperationDefinitionRest {
List<Link> links = new ArrayList<Link>();
List<SimplePropDef> params = new ArrayList<SimplePropDef>();
+ @ApiProperty("Name of the definition")
public String getName() {
return name;
}
@@ -30,6 +35,7 @@ public class OperationDefinitionRest {
this.name = name;
}
+ @ApiProperty("Id of the definition")
public int getId() {
return id;
}
@@ -51,6 +57,7 @@ public class OperationDefinitionRest {
links.add(link);
}
+ @ApiProperty("List of properties for this operation definition")
public List<SimplePropDef> getParams() {
return params;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationHistoryRest.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationHistoryRest.java
index 10967df..1731601 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationHistoryRest.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationHistoryRest.java
@@ -25,10 +25,14 @@ import java.util.Map;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* An operations history item
* @author Heiko W. Rupp
*/
+@ApiClass(value = "Denotes the outcome of an operation that has been scheduled to
run.")
@XmlRootElement
public class OperationHistoryRest {
@@ -42,6 +46,7 @@ public class OperationHistoryRest {
Map<String,Object> result = new HashMap<String, Object>();
List<Link> links = new ArrayList<Link>();
+ @ApiProperty(value = "The status of the history", allowableValues =
"In Progress, Cancelled, Failure, Success")
public String getStatus() {
return status;
}
@@ -50,6 +55,7 @@ public class OperationHistoryRest {
this.status = status;
}
+ @ApiProperty("Map with key/value pairs fo the operation result")
public Map<String, Object> getResult() {
return result;
}
@@ -58,6 +64,7 @@ public class OperationHistoryRest {
this.result = result;
}
+ @ApiProperty("Error message if the operation was not successful")
public String getErrorMessage() {
return errorMessage;
}
@@ -74,6 +81,7 @@ public class OperationHistoryRest {
this.links = links;
}
+ @ApiProperty("Name of the operation that was run")
public String getOperationName() {
return operationName;
}
@@ -82,6 +90,7 @@ public class OperationHistoryRest {
this.operationName = operationName;
}
+ @ApiProperty("Name of the resource the operation was run on")
public String getResourceName() {
return resourceName;
}
@@ -98,6 +107,7 @@ public class OperationHistoryRest {
this.lastModified = date;
}
+ @ApiProperty("Job-ID of this history item")
public String getJobId() {
return jobId;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationRest.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationRest.java
index 31f51dc..4cd3132 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationRest.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/OperationRest.java
@@ -8,10 +8,17 @@ import java.util.Map;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* @author Heiko W. Rupp
*/
@XmlRootElement
+@ApiClass(value = "Represents an operation to be scheduled.",
+ description = "You use this object to prepare the operation to be scheduled.
" +
+ "The object is derived from an OperationDefinition. When you are
ready preparing," +
+ "you need to set 'readyToSubmit' to true.")
public class OperationRest {
int id;
@@ -30,6 +37,7 @@ public class OperationRest {
this.definitionId = definitionId;
}
+ @ApiProperty("Id of the operation schedule")
public int getId() {
return id;
}
@@ -38,6 +46,7 @@ public class OperationRest {
this.id = id;
}
+ @ApiProperty("Name of the operation")
public String getName() {
return name;
}
@@ -46,6 +55,7 @@ public class OperationRest {
this.name = name;
}
+ @ApiProperty("Is this schedule ready to finally be submitted (and thus be
scheduled to run)")
public boolean isReadyToSubmit() {
return readyToSubmit;
}
@@ -54,6 +64,7 @@ public class OperationRest {
this.readyToSubmit = readyToSubmit;
}
+ @ApiProperty("The id of the resource the operation should run ")
public int getResourceId() {
return resourceId;
}
@@ -62,6 +73,7 @@ public class OperationRest {
this.resourceId = resourceId;
}
+ @ApiProperty("The id of the operation definition this schedule was created
from")
public int getDefinitionId() {
return definitionId;
}
@@ -70,6 +82,8 @@ public class OperationRest {
this.definitionId = definitionId;
}
+ @ApiProperty("A key/value map of parameters. Keys are strings. The map is
populated at the time the " +
+ "schedule is created from its definition")
public Map<String, Object> getParams() {
return params;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithChildren.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithChildren.java
index 3389493..2f4f699 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithChildren.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithChildren.java
@@ -23,10 +23,14 @@ import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* A lightweight resource with a list of children
* @author Heiko W. Rupp
*/
+@ApiClass("One resource with its direct child resources")
@XmlRootElement
public class ResourceWithChildren {
@@ -42,16 +46,19 @@ public class ResourceWithChildren {
this.name = name;
}
+ @ApiProperty("Id of the resource")
@XmlElement
public String getId() {
return id;
}
+ @ApiProperty("Name of the resource")
@XmlElement
public String getName() {
return name;
}
+ @ApiProperty("List of child resources")
@XmlElement
public List<ResourceWithChildren> getChildren() {
return children;
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithType.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithType.java
index 10030a9..6b9aace 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithType.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithType.java
@@ -33,17 +33,17 @@ import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
import org.jboss.resteasy.spi.touri.URITemplate;
/**
* A (partial) resource with some type information
* @author Heiko W. Rupp
*/
+@ApiClass("One resource")
@XmlRootElement(name="resource")
-/*
-(a)XmlAccessorType(XmlAccessType.NONE)
-@URITemplate("{id}")
-*/
public class ResourceWithType {
String resourceName;
@@ -67,6 +67,7 @@ public class ResourceWithType {
this.resourceId = id;
}
+ @ApiProperty("Name of the resource")
@XmlElement
public String getResourceName() {
return resourceName;
@@ -76,6 +77,7 @@ public class ResourceWithType {
this.resourceName = resourceName;
}
+ @ApiProperty("ID of the resource")
@XmlID
public String getResourceId() {
return String.valueOf(resourceId);
@@ -85,6 +87,7 @@ public class ResourceWithType {
this.resourceId = resourceId;
}
+ @ApiProperty("Name of the resource type of teh resource")
@XmlElement
public String getTypeName() {
return typeName;
@@ -94,6 +97,7 @@ public class ResourceWithType {
this.typeName = typeName;
}
+ @ApiProperty("Id of the resource type of the resource")
@XmlElement
public Integer getTypeId() {
return typeId;
@@ -103,6 +107,7 @@ public class ResourceWithType {
this.typeId = typeId;
}
+ @ApiProperty("Name of the plugin defining the resource type")
@XmlElement
public String getPluginName() {
return pluginName;
@@ -112,6 +117,7 @@ public class ResourceWithType {
this.pluginName = pluginName;
}
+ @ApiProperty("Id of the parent resource. Can be null if there is no parent (i.e.
the category is platform")
public Integer getParentId() {
return parentId;
}
@@ -137,6 +143,7 @@ public class ResourceWithType {
this.ancestry = ancestry;
}
+ @ApiProperty("The ancestry gives the path to the root resource")
public String getAncestry() {
return ancestry;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/SimplePropDef.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/SimplePropDef.java
index 08527fd..e4ebe24 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/SimplePropDef.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/SimplePropDef.java
@@ -21,12 +21,16 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
/**
* Simple property definition
* @author Heiko W. Rupp
*/
+@ApiClass(value = "A simple property definition", description = "This bean
is e.g. used for parameters of operations")
@XmlRootElement
public class SimplePropDef {
@@ -38,6 +42,7 @@ public class SimplePropDef {
public SimplePropDef() {
}
+ @ApiProperty("The name of the property")
public String getName() {
return name;
}
@@ -46,6 +51,7 @@ public class SimplePropDef {
this.name = name;
}
+ @ApiProperty("Indicates if the property is required i.e. has to have a value
set")
public boolean isRequired() {
return required;
}
@@ -54,6 +60,8 @@ public class SimplePropDef {
this.required = required;
}
+ @ApiProperty(value = "The type of the property",
+ allowableValues = "STRING, LONG_STRING, PASSWORD, BOOLEAN, INTEGER, LONG,
FLOAT, DOUBLE, FILE, DIRECTORY")
public PropertySimpleType getType() {
return type;
}
@@ -62,6 +70,7 @@ public class SimplePropDef {
this.type = type;
}
+ @ApiProperty("The string representation of a default value if defined.")
public String getDefaultValue() {
return defaultValue;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Status.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Status.java
index dfb64ab..63db3ee 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Status.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/Status.java
@@ -23,10 +23,14 @@ import java.util.Map;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* System status
* @author Heiko W. Rupp
*/
+@ApiClass("Place holder for the system status")
@XmlRootElement
public class Status {
@@ -34,6 +38,7 @@ public class Status {
public Status() {
}
+ @ApiProperty("Contains the status as a map of key/value pairs")
public Map<String, String> getValues() {
return values;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/StringValue.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/StringValue.java
index 64ceb70..dde8648 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/StringValue.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/StringValue.java
@@ -2,10 +2,14 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* Encapsulate a simple string value
* @author Heiko W. Rupp
*/
+@ApiClass("Encapsulates a simple string value")
@XmlRootElement
public class StringValue {
@@ -18,6 +22,7 @@ public class StringValue {
this.value = value;
}
+ @ApiProperty("The actual value")
public String getValue() {
return value;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/UserRest.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/UserRest.java
index 4cf9f70..727df3f 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/UserRest.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/UserRest.java
@@ -21,10 +21,14 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
/**
* A user
* @author Heiko W. Rupp
*/
+@ApiClass("Information about a user in RHQ")
@XmlRootElement
public class UserRest {
@@ -43,6 +47,7 @@ public class UserRest {
this.login = login;
}
+ @ApiProperty("The ID of the user")
public int getId() {
return id;
}
@@ -51,6 +56,7 @@ public class UserRest {
this.id = id;
}
+ @ApiProperty("The login name of the user")
public String getLogin() {
return login;
}
@@ -59,6 +65,7 @@ public class UserRest {
this.login = login;
}
+ @ApiProperty("The telephone number of the user")
public String getTel() {
return tel;
}
@@ -67,6 +74,7 @@ public class UserRest {
this.tel = tel;
}
+ @ApiProperty("The email address of the user")
public String getEmail() {
return email;
}
@@ -75,6 +83,7 @@ public class UserRest {
this.email = email;
}
+ @ApiProperty("The first name of the user")
public String getFirstName() {
return firstName;
}
@@ -83,6 +92,7 @@ public class UserRest {
this.firstName = firstName;
}
+ @ApiProperty("The last name of the user")
public String getLastName() {
return lastName;
}
commit b35fce00583384f57400a02409316ca76d440548
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Oct 24 14:10:43 2012 +0200
Make the rest docs generator understand the new @ApiClass annotation.
diff --git a/modules/helpers/rest-docs-generator/pom.xml
b/modules/helpers/rest-docs-generator/pom.xml
index 6bf8167..af3374f 100644
--- a/modules/helpers/rest-docs-generator/pom.xml
+++ b/modules/helpers/rest-docs-generator/pom.xml
@@ -146,7 +146,7 @@
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations_2.9.1</artifactId>
- <version>1.1-SNAPSHOT</version>
+ <version>1.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
diff --git
a/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
b/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
index 1d6c913..c10dd62 100644
---
a/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
+++
b/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
@@ -38,6 +38,7 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiClass;
import com.wordnik.swagger.annotations.ApiError;
import com.wordnik.swagger.annotations.ApiErrors;
import com.wordnik.swagger.annotations.ApiOperation;
@@ -170,7 +171,7 @@ public class ClassLevelProcessor extends AbstractProcessor {
log.debug("Looking at " +
classElementIn.getQualifiedName().toString());
// Process the data classes
- if (classElementIn.getAnnotation(XmlRootElement.class)!=null) {
+ if (classElementIn.getAnnotation(ApiClass.class)!=null) {
processDataClass(doc, classElementIn, xmlRoot);
return;
}
@@ -367,13 +368,23 @@ public class ClassLevelProcessor extends AbstractProcessor {
Element elem = doc.createElement("data");
xmlRoot.appendChild(elem);
elem.setAttribute("name",classElementIn.getSimpleName().toString());
- Api api = classElementIn.getAnnotation(Api.class);
+ ApiClass api = classElementIn.getAnnotation(ApiClass.class);
if (api!=null) {
elem.setAttribute("abstract",api.value());
if (api.description()!=null && !api.description().isEmpty()) {
elem.setAttribute("description",api.description());
}
}
+ // Determine the name of how the elements of this class are named in the XML /
JSON output
+ XmlRootElement rootElement = classElementIn.getAnnotation(XmlRootElement.class);
+ String objectName;
+ if (rootElement!=null) {
+ objectName = rootElement.name();
+ }
+ else {
+ objectName = classElementIn.getSimpleName().toString();
+ }
+ elem.setAttribute("objectName",objectName);
processDataClassProperties(doc, classElementIn, elem);
}
commit b4e1846e8434eab8810fc97ae6c35bcf6e54ecde
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Oct 10 09:00:05 2012 +0200
Follow up with the changes to SenderResult()
diff --git
a/modules/enterprise/server/plugins/alert-sms/src/main/java/org/rhq/enterprise/server/plugins/alertSms/SmsSender.java
b/modules/enterprise/server/plugins/alert-sms/src/main/java/org/rhq/enterprise/server/plugins/alertSms/SmsSender.java
index a3966be..65bde82 100644
---
a/modules/enterprise/server/plugins/alert-sms/src/main/java/org/rhq/enterprise/server/plugins/alertSms/SmsSender.java
+++
b/modules/enterprise/server/plugins/alert-sms/src/main/java/org/rhq/enterprise/server/plugins/alertSms/SmsSender.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * Copyright (C) 2005-2012 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -43,7 +43,6 @@ import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
import org.rhq.core.domain.alert.Alert;
-import org.rhq.core.domain.alert.notification.ResultState;
import org.rhq.core.domain.alert.notification.SenderResult;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.resource.Resource;
@@ -58,7 +57,6 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class SmsSender extends AlertSender {
private final Log log = LogFactory.getLog(SmsSender.class);
- private long TWO_MINUTES = 1000L * 60L * 2L;
private static final String DEVGARDEN_SMS_GW =
"https://gateway.developer.telekom.com/p3gw-mod-odg-sms/rest";
private static final String DEVGARDEN_SECURE_TOKEN_SERVER =
"https://sts.idm.telekom.com/rest-v1/tokens/odg";
private static final String TOKEN_EXPIRY_TIME = "token-expiry-time";
@@ -67,11 +65,13 @@ public class SmsSender extends AlertSender {
@Override
public SenderResult send(Alert alert) {
- String token = null;
+ String token;
try {
token = getToken();
} catch (Exception e) {
- return new SenderResult(ResultState.FAILURE, "Can not obtain token:
" + e.getMessage());
+ SenderResult senderResult = new SenderResult();
+ senderResult.addFailureMessage("Can not obtain token: " +
e.getMessage());
+ return senderResult;
}
Resource res = alert.getAlertDefinition().getResource();
@@ -87,10 +87,15 @@ public class SmsSender extends AlertSender {
try {
sendAlertSms(token,b.toString());
} catch (Exception e) {
- return new SenderResult(ResultState.FAILURE, "Failed to send SMS: "
+ e.getMessage());
+ SenderResult senderResult = new SenderResult();
+ senderResult.addFailureMessage("Failed to send SMS: " +
e.getMessage());
+ return senderResult;
}
- return new SenderResult(ResultState.SUCCESS, "SMS sent");
+ SenderResult senderResult = new SenderResult();
+ String tel = alertParameters.getSimpleValue("tel",null);
+ senderResult.addSuccessMessage("SMS to " + tel + " sent");
+ return senderResult;
}
/**
@@ -118,15 +123,14 @@ public class SmsSender extends AlertSender {
try {
ClientResponse resp = req.post(String.class);
if (resp.getStatus()==200) {
- System.out.println(resp.getEntity());
+ log.debug(resp.getEntity());
}
else {
- System.out.println("Fehler " + resp.getStatus());
- System.out.println(resp.getEntity());
+ log.warn("Error while sending SMS " + resp.getStatus());
+ log.debug(resp.getEntity());
throw new RuntimeException((String) resp.getEntity());
}
} catch (Exception e) {
- e.printStackTrace(); // TODO: Customise this generated block
throw (e);
}
@@ -146,7 +150,8 @@ public class SmsSender extends AlertSender {
if (tokenTimeProp!=null)
tokenExpTime = tokenTimeProp.getLongValue();
- if (token == null || tokenExpTime == null || tokenExpTime <
System.currentTimeMillis() + TWO_MINUTES ) {
+ long TWO_MINUTES = 1000L * 60L * 2L;
+ if (token == null || tokenExpTime == null || tokenExpTime <
System.currentTimeMillis() + TWO_MINUTES) {
String userId = preferences.getSimpleValue("login",null);
String password = preferences.getSimpleValue("password",null);
@@ -172,7 +177,7 @@ public class SmsSender extends AlertSender {
ClientResponse resp = request.get(String.class);
// TODO check status
- System.out.println(resp.getStatus());
+ log.debug(resp.getStatus());
String response = (String) resp.getEntity();
BufferedReader reader = new BufferedReader(new StringReader(response));
while (reader.ready()) {
@@ -182,7 +187,7 @@ public class SmsSender extends AlertSender {
break;
}
}
- System.out.println("Token: " + token);
+ log.debug("Token: " + token);
MultivaluedMap<String, List> headers = resp.getHeaders();
List expiresList = headers.get("Expires");
String expires = (String) expiresList.get(0);
@@ -207,7 +212,7 @@ public class SmsSender extends AlertSender {
mgr.mergeConfiguration(preferences);
} catch (Exception e) {
- e.printStackTrace(); // TODO: Customise this generated block
+ log.error("Error while retrieving a token: " +
e.getMessage());
throw e;
}
}