db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henn...@apache.org
Subject cvs commit: db-torque/src/generator/src/java/org/apache/torque/engine/database/model AppData.java Database.java NameFactory.java
Date Fri, 25 Jul 2003 16:40:31 GMT
henning     2003/07/25 09:40:31

  Modified:    src/generator/src/java/org/apache/torque/engine/database/model
                        AppData.java Database.java NameFactory.java
  Log:
  Do not log any problems when building or parsing the xml files. Generate
  consistently EngineException exceptions and throw them up the calling chain.
  
  This makes it possible to the callers (or ant/maven tasks) to react on
  problems when running torque tasks.
  
  Revision  Changes    Path
  1.4       +5 -1      db-torque/src/generator/src/java/org/apache/torque/engine/database/model/AppData.java
  
  Index: AppData.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/AppData.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AppData.java	29 Jun 2003 13:40:22 -0000	1.3
  +++ AppData.java	25 Jul 2003 16:40:30 -0000	1.4
  @@ -224,6 +224,7 @@
        * @return Database database
        */
       public Database getDatabase()
  +            throws EngineException
       {
           doFinalInitialization();
           return (Database) dbList.get(0);
  @@ -235,6 +236,7 @@
        * @return Array of Database objects
        */
       public Database[] getDatabases()
  +            throws EngineException
       {
           doFinalInitialization();
           int size = dbList.size();
  @@ -263,6 +265,7 @@
        * @return A Database object.  If it does not exist it returns null
        */
       public Database getDatabase (String name)
  +            throws EngineException
       {
           doFinalInitialization();
           for (Iterator i = dbList.iterator(); i.hasNext();)
  @@ -312,6 +315,7 @@
       }
   
       private void doFinalInitialization()
  +            throws EngineException
       {
           if (!isInitialized)
           {
  
  
  
  1.5       +51 -43    db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Database.java
  
  Index: Database.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Database.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Database.java	26 Jun 2003 06:59:56 -0000	1.4
  +++ Database.java	25 Jul 2003 16:40:30 -0000	1.5
  @@ -398,6 +398,7 @@
       }
   
       public void doFinalInitialization()
  +            throws EngineException
       {
           Table[] tables = getTables();
           for (int i = 0; i < tables.length; i++)
  @@ -423,7 +424,7 @@
                               + "' is marked as autoincrement, but it does not "
                               + "have a column which declared as the one to "
                               + "auto increment (i.e. autoIncrement=\"true\")\n";
  -                    log.error("Error in XML schema: " + errorMessage);
  +                    throw new EngineException("Error in XML schema: " + errorMessage);
                   }
               }
   
  @@ -437,57 +438,64 @@
                   Table foreignTable = getTable(currFK.getForeignTableName());
                   if (foreignTable == null)
                   {
  -                    log.error("ERROR!! Attempt to set foreign"
  +                    throw new EngineException("Attempt to set foreign"
                               + " key to nonexistent table, "
  -                            + currFK.getForeignTableName() + "!");
  +                            + currFK.getForeignTableName());
                   }
  -
  -                List referrers = foreignTable.getReferrers();
  -                if ((referrers == null || !referrers.contains(currFK)))
  -                {
  -                    foreignTable.addReferrer(currFK);
  -                }
  -
  -                // local column references
  -                Iterator localColumnNames = currFK.getLocalColumns().iterator();
  -                while (localColumnNames.hasNext())
  +                else
                   {
  -                    Column local = currTable
  -                        .getColumn((String) localColumnNames.next());
  -                    // give notice of a schema inconsistency.
  -                    // note we do not prevent the npe as there is nothing
  -                    // that we can do, if it is to occur.
  -                    if (local == null)
  +                    List referrers = foreignTable.getReferrers();
  +                    if ((referrers == null || !referrers.contains(currFK)))
                       {
  -                        log.error("ERROR!! Attempt to define foreign"
  -                                + " key with nonexistent column in table, "
  -                                + currTable.getName() + "!");
  +                        foreignTable.addReferrer(currFK);
                       }
  -                    //check for foreign pk's
  -                    if (local.isPrimaryKey())
  +
  +                    // local column references
  +                    Iterator localColumnNames = currFK.getLocalColumns().iterator();
  +                    while (localColumnNames.hasNext())
                       {
  -                        currTable.setContainsForeignPK(true);
  +                        Column local = currTable
  +                                .getColumn((String) localColumnNames.next());
  +                        // give notice of a schema inconsistency.
  +                        // note we do not prevent the npe as there is nothing
  +                        // that we can do, if it is to occur.
  +                        if (local == null)
  +                        {
  +                            throw new EngineException("Attempt to define foreign"
  +                                    + " key with nonexistent column in table, "
  +                                    + currTable.getName());
  +                        }
  +                        else
  +                        {
  +                            //check for foreign pk's
  +                            if (local.isPrimaryKey())
  +                            {
  +                                currTable.setContainsForeignPK(true);
  +                            }
  +                        }
                       }
   
  -                }
  -
  -                // foreign column references
  -                Iterator foreignColumnNames
  -                        = currFK.getForeignColumns().iterator();
  -                while (foreignColumnNames.hasNext())
  -                {
  -                    String foreignColumnName = (String) foreignColumnNames.next();
  -                    Column foreign = foreignTable.getColumn(foreignColumnName);
  -                    // if the foreign column does not exist, we may have an
  -                    // external reference or a misspelling
  -                    if (foreign == null)
  +                    // foreign column references
  +                    Iterator foreignColumnNames
  +                            = currFK.getForeignColumns().iterator();
  +                    while (foreignColumnNames.hasNext())
                       {
  -                        log.error("ERROR!! Attempt to set foreign"
  -                                + " key to nonexistent column: table="
  -                                +  currTable.getName() + ", foreign column=" 
  -                                +  foreignColumnName + "!");
  +                        String foreignColumnName = (String) foreignColumnNames.next();
  +                        Column foreign = foreignTable.getColumn(foreignColumnName);
  +                        // if the foreign column does not exist, we may have an
  +                        // external reference or a misspelling
  +                        if (foreign == null)
  +                        {
  +                            throw new EngineException("Attempt to set foreign"
  +                                    + " key to nonexistent column: table="
  +                                    +  currTable.getName() + ", foreign column=" 
  +                                    +  foreignColumnName);
  +                        }
  +                        else
  +                        {
  +                            foreign.addReferrer(currFK);
  +                        }
                       }
  -                    foreign.addReferrer(currFK);
                   }
               }
           }
  
  
  
  1.4       +5 -4      db-torque/src/generator/src/java/org/apache/torque/engine/database/model/NameFactory.java
  
  Index: NameFactory.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/NameFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- NameFactory.java	26 Jun 2003 06:59:56 -0000	1.3
  +++ NameFactory.java	25 Jul 2003 16:40:30 -0000	1.4
  @@ -112,6 +112,7 @@
        * @return A name generator
        */
       protected NameGenerator getAlgorithm(String name)
  +            throws EngineException
       {
           synchronized (algorithms)
           {
  @@ -125,12 +126,12 @@
                   }
                   catch (InstantiationException e)
                   {
  -                    log.error("Unable to instantiate class " + name
  -                            + ": Make sure it's in your run-time classpath");
  +                    throw new EngineException("Unable to instantiate class " 
  +                            + name + ": Make sure it's in your run-time classpath", e);
                   }
                   catch (Exception e)
                   {
  -                    log.error(e, e);
  +                    throw new EngineException(e);
                   }
                   algorithms.put(name, algorithm);
               }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message