Developer
Documentation
Resources
Get Support
Sign in
Developer
Get Support
Sign in
DOCUMENTATION
Cloud
Data Center
Resources
Sign in
Developer
Sign in
DOCUMENTATION
Cloud
Data Center
Resources
Sign in
Last updated Dec 8, 2017

REST resource for validating gadget configuration

The REST resource that is used to validate the configuration parameters of a gadget should simply return a 200 OK status if the parameters are valid.

If the configuration is not valid, the REST resource should return a 400 Bad Request status with a JSON format body containing error messages.

Error messages may either be general (e.g. pointing out an inter-field consistency problem) or specific to the value of a particular field.

1
2
{
    "errorMessages":
    {
        "start.date.before.end.date",
        "some.other.error"
    }
    "errors":
    {
        "field": "bugzillaUrl", "error": "gadget.bugzilla.invalid.url"
    }
}

Here's an example of Java JAXB annotated classes which produce suitable JSON:

1
2
@XmlRootElement
public class ErrorCollection
{
    /**
     * Generic error messages
     */
    @XmlElement
    private Collection<String> errorMessages = new ArrayList<String>();

    /**
     * Errors specific to a certain field.
     */
    @XmlElement
    private Collection<ValidationError> errors = new ArrayList<ValidationError>();

    ...
}
1
2
@XmlRootElement
public class ValidationError
{
    // The field the error relates to
    @XmlElement
    private String field;
    // The Error key...
    @XmlElement
    private String error;

    @XmlElement
    private Collection<String> params;

    ...
}

Creating a Gadget JavaScript Object

Rate this page: