Examples of DataServiceFault


Examples of org.wso2.carbon.dataservices.core.DataServiceFault

    super(dataService, queryId, queryParams, result, configId, inputEventTrigger,
        outputEventTrigger,  advancedProperties, inputNamespace);
    try {
        this.config = (ExcelConfig) this.getDataService().getConfig(this.getConfigId());
    } catch (ClassCastException e) {
      throw new DataServiceFault(e, "Configuration is not an Excel config:" +
          this.getConfigId());
    }   
    this.workbookName = workbookName;
    this.hasHeader = hasHeader;
    this.startingRow = startingRow;
    this.maxRowCount = maxRowCount;   
    if (DBUtils.isRegistryPath(config.getExcelDataSourcePath())) {
      /* register registry service listener */
      DataServicesDSComponent.registerRegistryServiceListener(this);
    } else {
      try {
        this.columnMappings = DBUtils.createColumnMappings(this.getHeader());
      } catch (Exception e) {
        throw new DataServiceFault(e, "Error in creating Excel column mappings.");
     

    }
   
  }
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

          count++;
        }
       
        return null;
    } catch (Exception e) {
      throw new DataServiceFault(e, "Error in ExcelQuery.runQuery.");
    }
  }
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

      this.keyColumns = keyColumns;
    this.query = query;
    try {
        this.config = (SQLConfig) this.getDataService().getConfig(this.getConfigId());
    } catch (ClassCastException e) {
      throw new DataServiceFault(e, "Configuration is not an SQL config:" +
          this.getConfigId());
    }
    init ();
   
  }
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

          ResultSet rs = this.getStoredProcFuncProps(
              this.extractStoredProcName(true));
          if (rs.isLast()) {
            rs = this.getStoredProcFuncProps(this.extractStoredProcName(false));
            if (rs.isLast()) {
              throw new DataServiceFault(
                  "Cannot find metadata for the stored procedure");
            }
          }
          /* stored procedures here can only have IN params and results which only
           * returns an integer, which has the update count,
           * all other situations are not supported for batch updates */
          StoredProcMetadataCollection mdCollection = new StoredProcMetadataCollection(rs);
          for (StoredProcMetdataEntry entry : mdCollection.getEntries()) {
            switch (entry.getColumnReturn()) {
            case DatabaseMetaData.procedureColumnIn:             
              break;
            case DatabaseMetaData.procedureColumnReturn:
              if (!(entry.getColumnDataType() == Types.INTEGER ||
                  entry.getColumnDataType() == Types.BIGINT
                  || entry.getColumnDataType() == Types.DECIMAL)) {
                return false;
              }
              break;
            default:
              return false;
            }
          }
          return true;
        } catch (SQLException e) {
          throw new DataServiceFault(e, "Error in retrieving database metadata");
        }
      } else {
        return true;
      }
    } else {
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

      if (AdvancedSQLProps.FETCH_DIRECTION_FORWARD.equals(fetchDirectionProp)) {
        this.fetchDirection = ResultSet.FETCH_FORWARD;
      } else if (AdvancedSQLProps.FETCH_DIRECTION_REVERSE.equals(fetchDirectionProp)) {
        this.fetchDirection = ResultSet.FETCH_REVERSE;
      } else {
        throw new DataServiceFault("Invalid fetch direction: " + fetchDirectionProp +
            ", valid values are {'" +  AdvancedSQLProps.FETCH_DIRECTION_FORWARD +
            "', '" + AdvancedSQLProps.FETCH_DIRECTION_REVERSE + "'}");
      }
      this.hasFetchDirection = true;     
    } else {
      this.hasFetchDirection = false;
    }
    /* process fetch size */
    String fetchSizeProp = props.get(RDBMS.FETCH_SIZE);
    if (!DBUtils.isEmptyString(fetchSizeProp)) {     
      fetchSizeProp = fetchSizeProp.trim();
      try {
        this.fetchSize = Integer.parseInt(fetchSizeProp);       
      } catch (NumberFormatException e) {
        throw new DataServiceFault(e, "Invalid fetch size: " + fetchSizeProp +
            ", fetch size should be an integer");
      }
      this.hasFetchSize = true;
    } else {
      this.hasFetchSize = false;
    }
    /* process max field size */
    String maxFieldSizeProp = props.get(RDBMS.MAX_FIELD_SIZE);
    if (!DBUtils.isEmptyString(maxFieldSizeProp)) {
      maxFieldSizeProp = maxFieldSizeProp.trim();
      try {
        this.maxFieldSize = Integer.parseInt(maxFieldSizeProp);
        if (this.maxFieldSize <= 0) {
          throw new DataServiceFault("Invalid maximum field size: " + maxFieldSizeProp +
              ", maximum field size should be a positive integer");
        }
      } catch (NumberFormatException e) {
        throw new DataServiceFault(e, "Invalid maximum field size: " + maxFieldSizeProp +
            ", maximum field size should be a positive integer");
      }
      this.hasMaxFieldSize = true;     
    } else {
      this.hasMaxFieldSize = false;
    }
    /* process max rows */
    String maxRowsProp = props.get(RDBMS.MAX_ROWS);
    if (!DBUtils.isEmptyString(maxRowsProp)) {
      maxRowsProp = maxRowsProp.trim();
      try {
        this.maxRows = Integer.parseInt(maxRowsProp);
        if (this.maxRows <= 0) {
          throw new DataServiceFault("Invalid maximum rows: " + maxRowsProp +
              ", maximum rows should be a positive integer");
        }
      } catch (NumberFormatException e) {
        throw new DataServiceFault(e, "Invalid maximum rows: " + maxRowsProp +
              ", maximum rows should be a positive integer");
      }
      this.hasMaxRows = true;     
    } else {
      this.hasMaxRows = false;
    }
    /* process query timeout */
    String queryTimeoutProp = props.get(RDBMS.QUERY_TIMEOUT);
    if (!DBUtils.isEmptyString(queryTimeoutProp)) {
      queryTimeoutProp = queryTimeoutProp.trim();
      try {
        this.queryTimeout = Integer.parseInt(queryTimeoutProp);
        if (this.queryTimeout <= 0) {
          throw new DataServiceFault("Invalid query timeout: " + queryTimeoutProp +
              ", query timeout be a positive integer");
        }
      } catch (NumberFormatException e) {
        throw new DataServiceFault(e, "Invalid query timeout: " + queryTimeoutProp +
              ", query timeout be a positive integer");
      }
      this.hasQueryTimeout = true;     
    } else {
      this.hasQueryTimeout = false;
    }
    /* auto commit */
    /* first check local auto commit setting */
    String autoCommitProp = props.get(RDBMS.AUTO_COMMIT);
    if (!DBUtils.isEmptyString(autoCommitProp)) {
      autoCommitProp = autoCommitProp.trim();
      try {
        boolean acBool = Boolean.parseBoolean(autoCommitProp);
        if (acBool) {
          this.autoCommit = AutoCommit.AUTO_COMMIT_ON;
        } else {
          this.autoCommit = AutoCommit.AUTO_COMMIT_OFF;
        }
      } catch (Exception e) {
        throw new DataServiceFault(e, "Invalid autocommit value: " + autoCommitProp +
              ", autocommit should be a boolean value");
      }           
    } else {
      /* global auto commit setting */
      this.autoCommit = this.getConfig().getAutoCommit();
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

    int i;
    for (i = 0; i < indices.length; i++) {
      tmpParam = params.getParam(indices[i]);
      remainingParams.remove(tmpParam);
      if (tmpParam == null) {
        throw new DataServiceFault(
            "A parameter is expected at position '" + (i + 1)
                + "' for the SQL query '" + this.getQuery() + "'");
      }
      if (indices[i] >= 0) {
          newParams.addParam(new InternalParam(tmpParam, i + 1));
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

          }           
          }         
        }
        return connection;
    } catch (SQLException e) {
      throw new DataServiceFault(e, "Error in opening DBMS connection.");
    }
  }
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

        connection.close();
      } else if (force) {
        connection.close();
      }
    } catch (SQLException e) {
      throw new DataServiceFault(e, "Error in DBMS connection finalize.");
    }
  }
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

      /* no pre-fetch data */
      return null;
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      isError = true;
      throw new DataServiceFault(e, FaultCodes.DATABASE_ERROR,
          "Error in 'SQLQuery.processNormalQuery'");
    } finally {
      /* finalize the DB connection, close it if possible etc.. */
      if (!prefetchData || isError) {       
        this.finalizeConnection(conn, isError);
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.DataServiceFault

     
      return null;
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      isError = true;
      throw new DataServiceFault(e, FaultCodes.DATABASE_ERROR,
          "Error in 'SQLQuery.processStoredProcQuery'");
    } finally {
      /* close the DB connection */
      if (!prefetchData) {
          this.finalizeConnection(conn, isError);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.