Package org.restsql.core

Examples of org.restsql.core.InvalidRequestException


        for (final TableMetaData table : metaData.getTables()) {
          final ColumnMetaData column = table.getColumns().get(param.getName());
          if (column != null) {
            if (column.isReadOnly()) {
              throw new InvalidRequestException(InvalidRequestException.MESSAGE_READONLY_PARAM,
                  column.getColumnLabel());
            }
            if (!column.isNonqueriedForeignKey()) {
              validParamFound = true;
              setNameValue(Request.Type.SELECT, metaData, column, param, true, sql, false);
            }
          }
        }
      }

      if (sql.getClause().length() > 0 && !validParamFound) {
        throw new InvalidRequestException(InvalidRequestException.MESSAGE_INVALID_PARAMS);
      }
    }
  }
View Full Code Here


    for (final RequestValue param : request.getParameters()) {
      for (final TableMetaData table : tables) {
        final ColumnMetaData column = table.getColumns().get(param.getName());
        if (column != null) {
          if (column.isReadOnly()) {
            throw new InvalidRequestException(InvalidRequestException.MESSAGE_READONLY_PARAM,
                column.getColumnLabel());
          }
          if (column.isPrimaryKey()) {
            // Add this to the res Ids - assume resIds is non null
            resIds.add(param);
          } else if (!column.isNonqueriedForeignKey()) {
            SqlStruct sql = sqls.get(column.getQualifiedTableName());
            if (sql == null) {
              // Create new sql holder
              sql = new SqlStruct(DEFAULT_UPDATE_SIZE, DEFAULT_UPDATE_SIZE / 2, true);
              sqls.put(column.getQualifiedTableName(), sql);
              sql.appendToBothMains("UPDATE ");
              sql.appendToBothMains(column.getQualifiedTableName());
              sql.appendToBothMains(" SET ");
            } else {
              sql.appendToBothMains(",");
            }

            validParamFound = true;
            setNameValue(request.getType(), metaData, column, param, false, sql, true);
          }
        }
      }
    }

    if (!validParamFound) {
      throw new InvalidRequestException(InvalidRequestException.MESSAGE_INVALID_PARAMS);
    }
    validParamFound = false;

    for (final String qualifiedTableName : sqls.keySet()) {
      final SqlStruct sql = sqls.get(qualifiedTableName);
      if (sql == null) {
        sqls.remove(qualifiedTableName);
      } else {
        // Iterate through the resourceIds and build the where clause sql for each table
        for (final RequestValue resId : resIds) {
          final TableMetaData table = metaData.getTableMap().get(qualifiedTableName);
          final ColumnMetaData column = table.getColumns().get(resId.getName());
          if (column != null) {
            if (sql.getClause().length() == 0) {
              sql.appendToBothClauses(" WHERE ");
            } else { // sql.getClause().length() > 0
              sql.appendToBothClauses(" AND ");
            }
            validParamFound = true;
            setNameValue(request.getType(), metaData, column, resId, true, sql, false);
          }
        }
        sql.compileStatements();
      }
    }

    if (!validParamFound) {
      throw new InvalidRequestException(InvalidRequestException.MESSAGE_INVALID_PARAMS);
    }
    return sqls;
  }
View Full Code Here

          break;
        case GreaterThanOrEqualTo:
          appendToBoth(sql, useMain, " >= ");
          break;
        default: // case Escaped
          throw new InvalidRequestException(
              "SqlBuilder.setNameValue() found unexpected operator of type "
                  + param.getOperator());
      }
    }
View Full Code Here

      parser = SAXParserFactory.newInstance().newSAXParser();
      inputStream = new ByteArrayInputStream(requestBody.getBytes());
      parser.parse(inputStream, handler);
    } catch (final Exception exception) {
      Config.logger.info("Error parsing request body for " + httpAttributes, exception);
      throw new InvalidRequestException("Error parsing request body: " + exception.toString());
    }
    final SqlResourceException handlerException = handler.getHandlerException();
    if (handlerException != null) {
      throw handlerException;
    }
View Full Code Here

TOP

Related Classes of org.restsql.core.InvalidRequestException

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.