Example #1
0
  /**
   * Extracts field metadata from an editmeta JSON object.
   *
   * @param name Field name
   * @param editmeta Edit metadata JSON object
   * @return a Meta instance with field metadata
   * @throws JiraException when the field is missing or metadata is bad
   */
  public static Meta getFieldMetadata(String name, JSONObject editmeta) throws JiraException {

    if (editmeta.isNullObject() || !editmeta.containsKey(name))
      throw new JiraException("Field '" + name + "' does not exist or read-only");

    Map f = (Map) editmeta.get(name);
    Meta m = new Meta();

    m.required = Field.getBoolean(f.get("required"));
    m.name = Field.getString(f.get("name"));

    if (!f.containsKey("schema"))
      throw new JiraException("Field '" + name + "' is missing schema metadata");

    Map schema = (Map) f.get("schema");

    m.type = Field.getString(schema.get("type"));
    m.items = Field.getString(schema.get("items"));
    m.system = Field.getString(schema.get("system"));
    m.custom = Field.getString(schema.get("custom"));
    m.customId = Field.getInteger(schema.get("customId"));

    return m;
  }
Example #2
0
  /**
   * Deserialize the json to extract standard attributes and keep a reference of other attributes.
   *
   * @param json The JSON object to read.
   */
  @Override
  void deserialize(JSONObject json) throws JiraException {
    super.deserialize(json);

    this.description = Field.getString(json.get("description"));
  }