Package com.google.visualization.datasource.base

Examples of com.google.visualization.datasource.base.DataSourceException


  public DataTable generateDataTable(Query query, HttpServletRequest request)
      throws DataSourceException {
    String url = request.getParameter(URL_PARAM_NAME);
    if (StringUtils.isEmpty(url)) {
      log.error("url parameter not provided.");
      throw new DataSourceException(ReasonType.INVALID_REQUEST, "url parameter not provided");
    }

    Reader reader;
    try {
      reader = new BufferedReader(new InputStreamReader(new URL(url).openStream()));
    } catch (MalformedURLException e) {
      log.error("url is malformed: " + url);
      throw new DataSourceException(ReasonType.INVALID_REQUEST, "url is malformed: " + url);
    } catch (IOException e) {
      log.error("Couldn't read from url: " + url, e);
      throw new DataSourceException(ReasonType.INVALID_REQUEST, "Couldn't read from url: " + url);
    }
    DataTable dataTable = null;
    ULocale requestLocale = DataSourceHelper.getLocaleFromRequest(request);
    try {
      // Note: We assume that all the columns in the CSV file are text columns. In cases where the
      // column types are known in advance, this behavior can be overridden by passing a list of
      // ColumnDescription objects specifying the column types. See CsvDataSourceHelper.read() for
      // more details.
      dataTable = CsvDataSourceHelper.read(reader, null, true, requestLocale);
    } catch (IOException e) {
      log.error("Couldn't read from url: " + url, e);
      throw new DataSourceException(ReasonType.INVALID_REQUEST, "Couldn't read from url: " + url);
    }
    return dataTable;
  }
View Full Code Here


    // Check for (!csv && !html && !tsv-excel) to make sure any output type
    // added in the future will be restricted to the same domain by default.
    OutputType outType = req.getDataSourceParameters().getOutputType();
    if (outType != OutputType.CSV && outType != OutputType.TSV_EXCEL
        && outType != OutputType.HTML && !req.isSameOrigin()) {
      throw new DataSourceException(ReasonType.ACCESS_DENIED,
          "Unauthorized request. Cross domain requests are not supported.");
    }
  }
View Full Code Here

        return splitSortAndPagination(query);
      case SELECT:
        return splitSelect(query);
    }
    log.error("Capabilities not supported.");
    throw new DataSourceException(ReasonType.NOT_SUPPORTED, "Capabilities not supported.");
  }
View Full Code Here

      buildRows(table, rs);
      return table;
    } catch (SQLException e) {
      String messageToUser = "Failed to execute SQL query. mySQL error message:"
          + " " + e.getMessage();
      throw new DataSourceException(
          ReasonType.INTERNAL_ERROR, messageToUser);
    } finally {
      if (stmt != null) {
        try {
          stmt.close();
View Full Code Here

      // Connect to the database.
      // We should add connection pooling to avoid heavy creation of connections.
      con = DriverManager.getConnection(url, userName, password);
    } catch (SQLException e) {
      log.error("Failed to connect to database server.", e);
      throw new DataSourceException(
          ReasonType.INTERNAL_ERROR, "Failed to connect to database server.");
    }
    return con;
  }
View Full Code Here

  static void appendFromClause(Query query,
      StrBuilder queryStringBuilder, String tableName)
      throws DataSourceException {
    if (StringUtils.isEmpty(tableName)) {
      log.error("No table name provided.");
      throw new DataSourceException(ReasonType.OTHER, "No table name provided.");
    }
    queryStringBuilder.append("FROM ");
    queryStringBuilder.append(tableName);
    queryStringBuilder.append(" ");
  }
View Full Code Here

        // Check for (!csv && !html && !tsv-excel) to make sure any output type
        // added in the future will be restricted to the same domain by default.
        OutputType outType = req.getDataSourceParameters().getOutputType();
        if(outType != OutputType.CSV && outType != OutputType.TSV_EXCEL
                && outType != OutputType.HTML && !req.isSameOrigin()) {
            throw new DataSourceException(ReasonType.ACCESS_DENIED,
                    "Unauthorized request. Cross domain requests are not supported.");
        }
    }
View Full Code Here

                return splitSortAndPagination(query);
            case SELECT:
                return splitSelect(query);
        }
        log.error("Capabilities not supported.");
        throw new DataSourceException(ReasonType.NOT_SUPPORTED, "Capabilities not supported.");
    }
View Full Code Here

      buildRows(table, rs);
      return table;
    } catch (SQLException e) {
      String messageToUser = "Failed to execute SQL query. mySQL error message:"
          + " " + e.getMessage();
      throw new DataSourceException(
          ReasonType.INTERNAL_ERROR, messageToUser);
    } finally {
      if (stmt != null) {
        try {
          stmt.close();
View Full Code Here

      // Connect to the database.
      // We should add connection pooling to avoid heavy creation of connections.
      con = DriverManager.getConnection(url, userName, password);
    } catch (SQLException e) {
      log.error("Failed to connect to database server.", e);
      throw new DataSourceException(
          ReasonType.INTERNAL_ERROR, "Failed to connect to database server.");
    }
    return con;
  }
View Full Code Here

TOP

Related Classes of com.google.visualization.datasource.base.DataSourceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.