/**
   * Displays configure form to enable market
   *
   * @param enterprise_id
   * @param enterprise_name
   */
  public static void enable(final Integer enterprise_id, final String enterprise_name) {
    Logger.info("------------------------- INSIDE Enable()-----------------");
    String user = session.get("username");
    String password = session.get("password");
    AbiquoContext context = Context.getApiClient(user, password);
    if (context != null) {
      try {
        List<MKT_Configuration> resultSet1 = MarketDAO.getMKTConfiguration(enterprise_id);

        if (resultSet1.size() == 0) {
          AbiquoUtils.setAbiquoUtilsContext(context);
          Iterable<Enterprise> enterpriseList = AbiquoUtils.getAllEnterprises();
          render(enterprise_id, enterprise_name, enterpriseList, user);
        } else {
          flash.error(" Market alredy configured. ");
          marketEnable();
        }

      } finally {
        flash.clear();
        if (context != null) {
          context.close();
        }
      }
    } else {
      flash.error("You are not connected.Please Login");
      Login.login_page();
    }
  }
  @Override
  public Iterable<VirtualAppliance> execute() {
    // Find virtual appliances in concurrent requests
    Iterable<VirtualDatacenter> vdcs = context.getCloudService().listVirtualDatacenters();
    Iterable<VirtualApplianceDto> vapps = listConcurrentVirtualAppliances(vdcs);

    return wrap(context, VirtualAppliance.class, vapps);
  }
  /** Lists all enterprises for market enablement */
  public static void marketEnable() {
    String user = session.get("username");
    String password = session.get("password");
    AbiquoContext context = Context.getApiClient(user, password);
    if (context != null) {
      AbiquoUtils.setAbiquoUtilsContext(context);
      try {
        Iterable<Enterprise> enterpriseList = AbiquoUtils.getAllEnterprises();

        ArrayList<EnterpriseEnabled> enterpriseEnabledList = new ArrayList<EnterpriseEnabled>();

        for (Enterprise enterprise : enterpriseList) {
          List<MKT_Configuration> resultSet = MarketDAO.getMKTConfiguration(enterprise.getId());

          boolean enabled = true;
          if (resultSet.size() == 0) {
            enabled = false;
          }
          EnterpriseEnabled enterpriseEnabled = new EnterpriseEnabled(enterprise, enabled);
          enterpriseEnabledList.add(enterpriseEnabled);
        }
        render(enterpriseEnabledList, user);
      } catch (Exception e) {
        flash.error("Unable to create context");
        render();
        // e.printStackTrace();

      } finally {
        flash.clear();
        if (context != null) {
          context.close();
        }
      }
    } else {
      flash.error("You are not connected.Please Login");
      Login.login_page();
    }
  }