Package com.google.visualization.datasource.base

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


    public DataTable create(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;
        ULocale requestLocale = DataSourceRequest.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


  public DataTable getDataTable(Feed dataFeed, FeedInfo feedInfo) throws DataSourceException {
    try {
      List<ColumnDescription> columnDescriptions = getColumnDescriptionsFromFeedInfo(feedInfo);
      return getDataTableFromFeed(dataFeed, columnDescriptions);
    } catch (FeedServerAdapterException e) {
      throw new DataSourceException(ReasonType.INTERNAL_ERROR, e.getMessage());
    }
  }
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.