/**
   * Returns all available resources.
   *
   * @return ComputeResource String
   */
  @Get
  public String getOCCIRequest() {
    // set occi version
    getServerInfo().setAgent(OcciConfig.getInstance().config.getString("occi.version"));
    LOGGER.debug("getReference().getLastSegment(): " + getReference().getLastSegment());

    // if there is something behind -, set bad request
    if (!getReference().getLastSegment().equals("-")) {
      getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
      return "There are no resources at the query interface.";
    }

    createQueryKinds();
    createQueryLinks();
    createQueryMixins();

    StringBuffer buffer = new StringBuffer();
    /*
     * Print all properties of the kind instance
     */
    for (Kind kind : queryKinds) {
      if (kind != null) {
        buffer.append("Category: " + kind.getTerm() + ";");
        buffer.append(" scheme=\"" + kind.getScheme() + "\";");
        // buffer.append("\r\n");
        buffer.append(" class=\"kind\"");
        buffer.append("\r\n");
        // append related scheme to buffer, if kind has a related kind
        if (kind.getRelated() != null) {
          for (Kind related : kind.getRelated()) {
            if (related != null) {
              buffer.append("\t\t rel=").append(related.getScheme()).append(";\n");
            }
          }
        }
        buffer.append("\t\t attributes=\"");
        if (kind.getAttributes() != null) {
          for (String attribute : kind.getAttributes()) {
            if (attribute != null) {
              buffer.append(attribute).append(" ");
            }
          }
        }
        buffer.append("\";\n");
        buffer.append("\t\t actions=");
        for (String actionName : kind.getActionNames()) {
          if (actionName != null) {
            buffer.append(actionName).append(" ");
          }
        }
        buffer.append(";");
        buffer.append("\r\n");
        buffer.append("\t\t location=/").append(kind.getTerm()).append("/;");
        buffer.append("\r\n");
      }
    }

    /*
     * Print all link properties.
     */
    for (Link link : queryLinks) {
      if (link != null) {
        buffer.append("Category: ").append(link.getKind().getTerm()).append(";");
        buffer.append("\t\t scheme=\"").append(link.getKind().getScheme()).append("\";");
        buffer.append("\r\n");
        buffer.append("\t\t class=\"link\";");
        buffer.append("\r\n");
        // append related scheme to buffer, if kind has a related kind
        if (link.getKind().getRelated() != null) {
          for (Kind related : link.getKind().getRelated()) {
            if (related != null) {
              buffer.append("\t\t rel=").append(related.getScheme()).append(";\n");
            }
          }
        }
        buffer.append("\t\t attributes=\"");
        if (link.getKind().getAttributes() != null) {
          for (String attribute : link.getKind().getAttributes()) {
            if (attribute != null) {
              buffer.append(attribute + " ");
            }
          }
        }
        buffer.append("\";\n");
        buffer.append("\t\t actions=");
        for (String actionName : link.getKind().getActionNames()) {
          if (actionName != null) {
            buffer.append(actionName).append(" ");
          }
        }
        buffer.append(";");
        buffer.append("\r\n");
        buffer.append("\t\t location=/").append(link.getKind().getTerm()).append("/;");
        buffer.append("\r\n");
      }
    }

    /*
     * Print all properties of the mixin instance
     */

    if (ipNetworkInterface != null) {
      buffer.append("Category: ").append(ipNetworkInterface.getTitle()).append(";");
      buffer.append("\t\t scheme=\"").append(ipNetworkInterface.getScheme()).append("\";");
      buffer.append("\r\n");
      buffer.append("\t\t class=\"mixin\"");
      buffer.append("\r\n");
      // append related scheme to buffer, if kind has a related
      // kind
      if (ipNetworkInterface.getRelated() != null) {
        for (Mixin related : ipNetworkInterface.getRelated()) {
          if (related != null) {
            buffer.append("\t\t rel=").append(related.getScheme()).append(";\n");
          }
        }
      }
      buffer.append("\t\t attributes=\"");
      if (ipNetworkInterface.getAttributes() != null) {
        for (String attribute : ipNetworkInterface.getAttributes()) {
          if (attribute != null) {
            buffer.append(attribute).append(" ");
          }
        }
      }
      buffer.append("\";\n");
      buffer.append("\t\t location=/").append(ipNetworkInterface.getTerm()).append("/;");
      buffer.append("\r\n");
    }

    /*
     * Print all properties of the mixin instance
     */
    for (Mixin mixin : Mixin.getMixins()) {
      if (mixin != null && !mixin.getTerm().equals("ipnetwork")) {
        buffer.append("Category: " + mixin.getTitle()).append(";");

        buffer.append("\r\n");
        buffer.append("\t\t class=\"mixin\"");
        buffer.append("\r\n");
        // append related scheme to buffer, if kind has a related
        // kind
        if (mixin.getRelated() != null) {
          for (Mixin related : mixin.getRelated()) {
            if (related != null) {
              buffer.append("\t\t rel=").append(related.getScheme()).append(";\n");
            }
          }
        }
        buffer.append("\t\t scheme=").append(mixin.getScheme()).append(";");
        buffer.append("\r\n");
        buffer.append("\t\t location=/").append(mixin.getTerm()).append("/;");
        buffer.append("\r\n");
      }
    }
    buffer.append("\r\n");

    // Generate all action names list
    Network.generateActionNames();
    Storage.generateActionNames();
    Compute.generateActionNames();

    /*
     * Print all action names.
     */
    for (String computeAction : Compute.getActionNames()) {
      if (computeAction.contains("#")) {
        buffer
            .append("Category: " + computeAction.substring(computeAction.lastIndexOf("#") + 1))
            .append(";");
      } else {
        buffer.append("Cagegory: action;");
      }
      buffer
          .append(" scheme=\"" + computeAction.substring(0, computeAction.lastIndexOf("#") + 1))
          .append("\"\n");

      if (computeAction.contains("#start")) {
        // buffer.append(" attributes: ");
      } else if (computeAction.contains("#stop")) {
        // buffer.append(" attributes: "
        // + StopAction.getStopAttributesAsString() + " ");
      } else if (computeAction.contains("#restart")) {
        // buffer.append(" attributes: "
        // + RestartAction.getRestartAttributesAsString()
        // + " ");
      } else if (computeAction.contains("#suspend")) {
        // buffer.append(" attributes: "
        // + SuspendAction.getSuspendAttributesAsString()
        // + " ");
      }
    }

    for (String storageAction : Storage.getActionNames()) {
      if (storageAction.contains("#")) {
        buffer
            .append("Category: ")
            .append(storageAction.substring(storageAction.lastIndexOf("#") + 1))
            .append(";");
      } else {
        buffer.append("Cagegory: action;");
      }
      buffer
          .append("\t\t scheme=\"")
          .append(storageAction.substring(0, storageAction.lastIndexOf("#") + 1))
          .append("\"\n");
    }

    for (String networkAction : Network.getActionNames()) {
      if (networkAction.contains("#")) {
        buffer
            .append("Category: " + networkAction.substring(networkAction.lastIndexOf("#") + 1))
            .append(";");
      } else {
        buffer.append("Cagegory: action;");
      }
      buffer
          .append("\t\t scheme=\"" + networkAction.substring(0, networkAction.lastIndexOf("#") + 1))
          .append("\"\n");
    }

    // access the request headers and get the Accept attribute of the
    // Content-Type
    Form requestHeaders = (Form) getRequest().getAttributes().get("org.restlet.http.headers");
    Representation representation =
        OcciCheck.checkContentType(requestHeaders, buffer, getResponse());
    LOGGER.debug("Raw Request headers: " + requestHeaders.toString());

    /*
     * if content type equals text/occi, render query information in the
     * header and NOT in the body
     */
    if (representation.getMediaType().toString().equals("text/occi")) {
      // Generate the header rendering if media-type equals text/occi
      OcciCheck occiCheck = new OcciCheck();
      occiCheck.setHeaderRendering((LinkedList<Kind>) queryKinds);
      getResponse().setEntity(representation);
      return " ";
    }
    // add content type and status to client response
    getResponse().setEntity(representation);
    return " ";
  }
  /** Creates the list with kind instances necessary for the query list. */
  private void createQueryKinds() {
    // add the actions to the action list
    /** *IaaS***** */
    HashSet<String> computeActionNames = Compute.generateActionNames();
    HashSet<String> networkActionNames = Network.generateActionNames();
    HashSet<String> storageActionNames = Storage.generateActionNames();
    /** **PaaS */
    HashSet<String> containerActionNames = Container.generateActionNames();
    HashSet<String> databaseActionNames = Database.generateActionNames();

    /** **SaaS */
    HashSet<String> applicationActionNames = Application.generateActionNames();
    HashSet<String> environmentActionNames = Environment.generateActionNames();
    HashSet<String> deployableActionNames = Deployable.generateActionNames();

    // generate list with actions
    /** *IaaS***** */
    HashSet<Action> computeActionSet = Compute.generateActionSet();
    HashSet<Action> networkActionSet = Network.generateActionSet();
    HashSet<Action> storageActionSet = Storage.generateActionSet();
    /** **PaaS */
    HashSet<Action> containerActionSet = Container.generateActionSet();
    HashSet<Action> databaseActionSet = Database.generateActionSet();
    /** **SaaS */
    HashSet<Action> applicationActionSet = Application.generateActionSet();
    HashSet<Action> environmentActionSet = Environment.generateActionSet();
    HashSet<Action> deployableActionSet = Deployable.generateActionSet();

    /** *IaaS***** */
    Compute.generateAttributeList();
    Network.generateAttributeList();
    Storage.generateAttributeList();
    /** **PaaS */
    Container.generateAttributeList();
    Database.generateAttributeList();
    /** **SaaS */
    Application.generateAttributeList();
    Environment.generateAttributeList();
    Deployable.generateAttributeList();
    try {
      // create a related Kind and add it to the list for the query
      // interface
      HashSet<Kind> relatedSet = new HashSet<Kind>();
      Kind related =
          new Kind(
              null,
              null,
              null,
              null,
              "storage",
              "storage",
              "http://schemas.ogf.org/occi/core#resource",
              null);
      relatedSet.add(related);
      // create compute kind and add to kind list
      Kind compute =
          new Kind(
              computeActionSet,
              relatedSet,
              null,
              null,
              "compute",
              "compute",
              "http://schemas.ogf.org/occi/infrastructure#",
              Compute.getAttributes());

      compute.setActionNames(computeActionNames);
      queryKinds.add(compute);
      // create storage kind and add to kind list
      Kind storage =
          new Kind(
              storageActionSet,
              relatedSet,
              null,
              null,
              "storage",
              "storage",
              "http://schemas.ogf.org/occi/infrastructure#",
              Storage.getAttributes());
      storage.setActionNames(storageActionNames);
      queryKinds.add(storage);
      // create network kind and add to kind list
      Kind network =
          new Kind(
              networkActionSet,
              relatedSet,
              null,
              null,
              "network",
              "network",
              "http://schemas.ogf.org/occi/infrastructure#",
              Network.getAttributes());
      network.setActionNames(networkActionNames);
      queryKinds.add(network);

      // create container kind and add to kind list
      Kind container =
          new Kind(
              containerActionSet,
              relatedSet,
              null,
              null,
              "container",
              "container",
              "http://schemas.ogf.org/occi/platform#",
              Container.getAttributes());
      container.setActionNames(containerActionNames);
      queryKinds.add(container);

      // create database kind and add to kind list
      Kind database =
          new Kind(
              databaseActionSet,
              relatedSet,
              null,
              null,
              "database",
              "database",
              "http://schemas.ogf.org/occi/platform#",
              Database.getAttributes());
      database.setActionNames(databaseActionNames);
      queryKinds.add(database);

      // create application kind and add to kind list
      Kind application =
          new Kind(
              applicationActionSet,
              relatedSet,
              null,
              null,
              "application",
              "application",
              "http://schemas.ogf.org/occi/application#",
              Application.getAttributes());
      application.setActionNames(applicationActionNames);
      queryKinds.add(application);

      // create environment kind and add to kind list
      Kind environment =
          new Kind(
              environmentActionSet,
              relatedSet,
              null,
              null,
              "environment",
              "environment",
              "http://schemas.ogf.org/occi/application#",
              Environment.getAttributes());
      environment.setActionNames(environmentActionNames);
      queryKinds.add(environment);

      // create deployable kind and add to kind list
      Kind deployable =
          new Kind(
              deployableActionSet,
              relatedSet,
              null,
              null,
              "deployable",
              "deployable",
              "http://schemas.ogf.org/occi/application#",
              Deployable.getAttributes());
      deployable.setActionNames(deployableActionNames);
      queryKinds.add(deployable);

    } catch (Exception e) {
      // create log message
      e.printStackTrace();
    }
  }