/** {@inheritDoc} */
  @Override
  public void describeGet(MethodInfo mInfo) {
    mInfo.setIdentifier("ContactsList");
    mInfo.setDocumentation("To Retrieve a sorted list of contacts");

    RequestInfo requestInfo = new RequestInfo();
    ParameterInfo pInfo = createCommonParameter(REQUEST_QUERY_SORT, "Sort query", LAST_NAME);
    pInfo.getOptions().add(createOptionInfo(FIRST_NAME, "Sort by first name"));
    pInfo.getOptions().add(createOptionInfo(LAST_NAME, "Sort by last name"));
    pInfo.getOptions().add(createOptionInfo(MAIL, "Sort by Email"));
    pInfo.getOptions().add(createOptionInfo(PHONE, "Sort by Phone"));

    requestInfo.getParameters().add(pInfo);
    mInfo.setRequest(requestInfo);

    ResponseInfo response = new ResponseInfo("Current list of contacts");
    response.getStatuses().add(Status.SUCCESS_OK);

    RepresentationInfo repInfo = new RepresentationInfo(MediaType.APPLICATION_XML);
    repInfo.setXmlElement(CONTACTS);
    repInfo.setDocumentation("XML List of contacts");
    response.getRepresentations().add(repInfo);

    repInfo = new RepresentationInfo(MediaType.APPLICATION_JSON);
    repInfo.setXmlElement(CONTACTS);
    repInfo.setDocumentation("JSON List of contacts");
    response.getRepresentations().add(repInfo);

    mInfo.getResponses().add(response);
  }
 /**
  * Describe the GET method
  *
  * @param info the WADL documentation info
  */
 public void describeGet(MethodInfo info) {
   info.setDocumentation("Method to get the admin view.");
   this.addStandardGetRequestInfo(info);
   ResponseInfo responseInfo = new ResponseInfo();
   RepresentationInfo representationInfo = new RepresentationInfo();
   representationInfo.setReference("html_freemarker");
   responseInfo.getRepresentations().add(representationInfo);
   info.getResponses().add(responseInfo);
 }
  @Override
  public void updateNamespaces(Map<String, String> namespaces) {
    namespaces.putAll(resolveNamespaces());

    for (final RepresentationInfo representationInfo : getRepresentations()) {
      representationInfo.updateNamespaces(namespaces);
    }

    for (final ParameterInfo parameterInfo : getParameters()) {
      parameterInfo.updateNamespaces(namespaces);
    }
  }
  /**
   * Writes the current object as an XML element using the given SAX writer.
   *
   * @param writer The SAX writer.
   * @throws SAXException
   */
  public void writeElement(XmlWriter writer) throws SAXException {
    AttributesImpl attributes = new AttributesImpl();

    if ((getStatuses() != null) && !getStatuses().isEmpty()) {
      StringBuilder builder = new StringBuilder();

      for (Iterator<Status> iterator = getStatuses().iterator(); iterator.hasNext(); ) {
        Status status = iterator.next();
        builder.append(status.getCode());
        if (iterator.hasNext()) {
          builder.append(" ");
        }
      }

      attributes.addAttribute("", "status", null, "xs:string", builder.toString());
    }

    if (getDocumentations().isEmpty()
        && getParameters().isEmpty()
        && getRepresentations().isEmpty()) {
      writer.emptyElement(APP_NAMESPACE, "response", null, attributes);
    } else {
      writer.startElement(APP_NAMESPACE, "response", null, attributes);

      for (DocumentationInfo documentationInfo : getDocumentations()) {
        documentationInfo.writeElement(writer);
      }

      for (ParameterInfo parameterInfo : getParameters()) {
        parameterInfo.writeElement(writer);
      }

      for (RepresentationInfo representationInfo : getRepresentations()) {
        representationInfo.writeElement(writer);
      }

      writer.endElement(APP_NAMESPACE, "response");
    }
  }
  /**
   * Descibes the GET method in WADL.
   *
   * @param info information
   */
  @Override
  protected final void describeGet(final MethodInfo info) {
    this.addInfo(info);
    info.setIdentifier("NameResolver");
    info.setDocumentation("Get the object's coordinates from its name and time for planets.");

    // objecName parameter
    final List<ParameterInfo> parametersInfo = new ArrayList<ParameterInfo>();
    parametersInfo.add(
        new ParameterInfo(
            "objectName", true, "String", ParameterStyle.TEMPLATE, "Object name to resolve"));

    // reference frame parameter
    final ParameterInfo paramCoordSys =
        new ParameterInfo(
            "coordSystem",
            true,
            "String",
            ParameterStyle.TEMPLATE,
            "Coordinate system in which the output is formated");
    final List<OptionInfo> coordsysOption = new ArrayList<OptionInfo>();
    final OptionInfo optionEquatorial = new OptionInfo("Equatorial system in ICRS");
    optionEquatorial.setValue(CoordinateSystem.EQUATORIAL.name());
    coordsysOption.add(optionEquatorial);
    final OptionInfo optionGalactic = new OptionInfo("Galactic system");
    optionGalactic.setValue(CoordinateSystem.GALACTIC.name());
    coordsysOption.add(optionGalactic);
    paramCoordSys.setOptions(coordsysOption);
    parametersInfo.add(paramCoordSys);

    // Name resolver parameter
    final ParameterInfo nameResolverParam =
        new ParameterInfo(
            "nameResolver", false, "String", ParameterStyle.QUERY, "The selected name resolver");
    final List<OptionInfo> nameResolverOption = new ArrayList<OptionInfo>();
    final OptionInfo optionCDS = new OptionInfo("The CDS name resolver based on SIMBAD and NED");
    optionCDS.setValue("CDS");
    nameResolverOption.add(optionCDS);
    final OptionInfo optionIAS = new OptionInfo("The IAS name resolver for Corot");
    optionIAS.setValue("IAS");
    nameResolverOption.add(optionIAS);
    nameResolverParam.setOptions(nameResolverOption);
    final OptionInfo optionIMCCE =
        new OptionInfo("The IMCEE name resolver for solar system bodies");
    optionIMCCE.setValue("IMCCE");
    nameResolverOption.add(optionIMCCE);
    nameResolverParam.setOptions(nameResolverOption);
    final OptionInfo optionAll = new OptionInfo("Query all name resolvers");
    optionAll.setValue("ALL");
    nameResolverOption.add(optionAll);
    final String nameResolverFromModel =
        this.getModel().getParameterByName("nameResolver").getValue();
    final String defaultNameResolver =
        (nameResolverFromModel != null && !nameResolverFromModel.isEmpty())
            ? nameResolverFromModel
            : "CDS";
    nameResolverParam.setDefaultValue(defaultNameResolver);
    parametersInfo.add(nameResolverParam);

    // Time frame for IMCCE
    final ParameterInfo time =
        new ParameterInfo(
            "epoch",
            false,
            "String",
            ParameterStyle.QUERY,
            "Time frame for IMCCE name resolver. See documentation from IMCCE");
    final String timeFromModel = this.getModel().getParameterByName("epoch").getValue();
    final String defaultTime =
        (timeFromModel != null && !timeFromModel.isEmpty()) ? timeFromModel : "now";
    time.setDefaultValue(defaultTime);
    parametersInfo.add(time);

    // Set all parameters
    info.getRequest().setParameters(parametersInfo);

    // Response OK
    final ResponseInfo responseOK = new ResponseInfo();
    List<RepresentationInfo> representationsInfo = new ArrayList<RepresentationInfo>();
    RepresentationInfo representationInfo = new RepresentationInfo(MediaType.APPLICATION_JSON);
    final DocumentationInfo doc = new DocumentationInfo();
    doc.setTitle("Name Resolver representation");
    doc.setTextContent(
        "<pre>{\n"
            + "totalResults: 1,\n"
            + "type: \"FeatureCollection\",\n"
            + "features: [\n"
            + "  geometry: {\n"
            + "    coordinates: [10.6847083,41.26875],\n"
            + "    type: \"Point\"\n"
            + "  },\n"
            + "properties: {\n"
            + "  crs: {\n"
            + "    type: \"name\",\n"
            + "    properties: {\n"
            + "      name: \"EQUATORIAL.ICRS\"\n"
            + "    }\n"
            + "  },\n"
            + "  credits: \"CDS\",\n"
            + "  identifier: \"CDS0\"\n"
            + "}\n"
            + "}]}</pre>");
    representationInfo.setDocumentation(doc);
    representationsInfo.add(representationInfo);
    responseOK.getRepresentations().add(representationInfo);
    responseOK.getStatuses().add(Status.SUCCESS_OK);

    // response bad request and internal error
    representationsInfo = new ArrayList<RepresentationInfo>();
    representationInfo = new RepresentationInfo(MediaType.TEXT_HTML);
    representationInfo.setDocumentation("SITools2 status error page");
    representationsInfo.add(representationInfo);

    final ResponseInfo responseError = new ResponseInfo();
    responseError.getRepresentations().add(representationInfo);
    responseError.getStatuses().add(Status.SERVER_ERROR_INTERNAL);
    responseError.setDocumentation("Unexpected error");

    final ResponseInfo responseBad = new ResponseInfo();
    responseBad.getRepresentations().add(representationInfo);
    responseBad.getStatuses().add(Status.CLIENT_ERROR_BAD_REQUEST);
    responseBad.setDocumentation(
        Status.CLIENT_ERROR_BAD_REQUEST.getDescription() + "- coordinate system is unknown");

    final ResponseInfo responseNotFound = new ResponseInfo();
    responseNotFound.getRepresentations().add(representationInfo);
    responseNotFound.getStatuses().add(Status.CLIENT_ERROR_NOT_FOUND);
    responseNotFound.setDocumentation("object not found.");

    final ResponseInfo responseUnavailable = new ResponseInfo();
    responseUnavailable.getRepresentations().add(representationInfo);
    responseUnavailable.getStatuses().add(Status.SERVER_ERROR_SERVICE_UNAVAILABLE);
    responseUnavailable.setDocumentation(Status.SERVER_ERROR_SERVICE_UNAVAILABLE.getDescription());

    // Set responses
    final List<ResponseInfo> responseInfo = new ArrayList<ResponseInfo>();
    responseInfo.add(responseOK);
    responseInfo.add(responseError);
    responseInfo.add(responseBad);
    responseInfo.add(responseUnavailable);
    responseInfo.add(responseNotFound);
    info.getResponses().addAll(responseInfo);
  }