db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: jakarta-ojb/src/java/org/apache/ojb/broker/ant RepositoryVerifierHandler.java
Date Tue, 24 Dec 2002 13:38:04 GMT
arminw      2002/12/24 05:38:04

  Modified:    src/java/org/apache/ojb/broker/ant
                        RepositoryVerifierHandler.java
  Log:
  small fix
  
  Revision  Changes    Path
  1.10      +71 -71    jakarta-ojb/src/java/org/apache/ojb/broker/ant/RepositoryVerifierHandler.java
  
  Index: RepositoryVerifierHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/ant/RepositoryVerifierHandler.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- RepositoryVerifierHandler.java	22 Dec 2002 16:35:17 -0000	1.9
  +++ RepositoryVerifierHandler.java	24 Dec 2002 13:38:04 -0000	1.10
  @@ -93,7 +93,7 @@
       private String m_CurrentString;
       private VerifyMappingsTask m_callingTask;
       private DBUtility m_dBUtility;
  -    
  +
       //ClassDescriptor members;
       //private String m_CurrentClass = "";
       private Class m_currentClass = null;
  @@ -103,20 +103,20 @@
       /** the default isolation level*/
       private int defIsoLevel = IL_DEFAULT;
   
  -    /** 
  +    /**
        * All known xml tags are kept in this table.
        * The tags table allows lookup from literal to id
        * and from id to literal.
        */
       private RepositoryTags tags = RepositoryTags.getInstance();
  -    
  +
       private Collection m_VerifyExceptions = new ArrayList(69);
       private Collection m_VerifyWarnings = new ArrayList(69);
   
   
       /**
        * The only public constructor for RepositoryVerifierHandler.
  -     * 
  +     *
        * @param callingTask	A reference to the ant task using this parser.
        */
       public RepositoryVerifierHandler(VerifyMappingsTask callingTask)
  @@ -124,13 +124,13 @@
           m_callingTask = callingTask;
           m_callingTask.logWarning("Loaded RepositoryVerifierHandler.");
           logger = LoggerFactory.getLogger(this.getClass());
  -    } 
  -    
  +    }
  +
       /**
        * returns the XmlCapable id associated with the literal.
        * OJB maintains a RepositoryTags table that provides
        * a mapping from xml-tags to XmlCapable ids.
  -     * 
  +     *
        * @param literal the literal to lookup
        * @return the int value representing the XmlCapable
        *
  @@ -148,7 +148,7 @@
               throw new MetadataException("unknown literal: '" + literal + "'",t);
           }
   
  -    }   
  +    }
   
       /**
        * startDocument callback, nothing to do here.
  @@ -186,7 +186,7 @@
                           break;
                       }
                   case JDBC_CONNECTION_DESCRIPTOR :
  -                    {                    	
  +                    {
                           m_CurrentJCD = new JdbcConnectionDescriptor();
   
                           // set platform attribute
  @@ -233,10 +233,10 @@
                           String password = atts.getValue(tags.getTagById(USER_PASSWD));
                           //logger.debug("     " + tags.getTagById(User_passwd) + ": " +
password);
                           m_CurrentJCD.setPassWord(password);
  -                        
  +
                           //connect to the database
                           m_dBUtility = getDBUtility(m_CurrentJCD);
  -						
  +
                           break;
                       }
                   case CLASS_DESCRIPTOR :
  @@ -255,7 +255,7 @@
                               //logger.error(ex);
                               throw new MetadataException("Can't load class-descriptor class
'" + classname + "'.");
                           }
  -                        
  +
                           m_CurrentTable = atts.getValue(tags.getTagById(TABLE_NAME));
   
                           if (m_CurrentTable != null)
  @@ -266,14 +266,14 @@
                               	throw new MetadataException("The table '" + m_CurrentTable
+ "' does not exist in the database.");
                               }
                           }
  -                                                                       
  +
   
                           break;
                       }
   
                   case CLASS_EXTENT :
                       {
  -                    	
  +
                           String classname = atts.getValue("class-ref");
   
                           try
  @@ -284,28 +284,28 @@
                           {
                               //logger.error(ex);
                               throw new MetadataException("Can't load extent-class class
'" + classname + "'.");
  -                        }                        
  +                        }
                           break;
                       }
   
                   case FIELD_DESCRIPTOR :
                       {
                           int id = Integer.parseInt(atts.getValue("id"));
  -                        m_CurrentFLD = new FieldDescriptor(id);
  +                        m_CurrentFLD = new FieldDescriptor(null, id);
   
                           String fieldName = atts.getValue(tags.getTagById(FIELD_NAME));
   
                           if (m_currentClass != null)
                           {
                           	//this.m_callingTask.logWarning("Verifying " + fieldName + " in
class " + m_currentClass.toString());
  -							confirmFieldExists(m_currentClass, fieldName);                     
  -	
  +							confirmFieldExists(m_currentClass, fieldName);
  +
   	                        String columnName = atts.getValue(tags.getTagById(COLUMN_NAME));
   	                        m_CurrentFLD.setColumnName(columnName);
  -	
  +
   	                        String jdbcType = atts.getValue(tags.getTagById(JDBC_TYPE));
   	                        m_CurrentFLD.setColumnType(jdbcType);
  -	                        
  +
   	                        //check that the field exists in the database
   	                        if(m_currentTableExists)
   	                        {
  @@ -315,12 +315,12 @@
   	                        	}
   	                        	else
   	                        	{
  -									m_dBUtility.existsUseWarnings(m_CurrentTable, columnName, jdbcType, m_callingTask.getIgnoreFieldNameCase());
                        		
  +									m_dBUtility.existsUseWarnings(m_CurrentTable, columnName, jdbcType, m_callingTask.getIgnoreFieldNameCase());
   	                        	}
   	                        }
  -	                        
  +
                           }
  -                        
  +
                           break;
                       }
                   case REFERENCE_DESCRIPTOR :
  @@ -330,7 +330,7 @@
                           	//Confirm that this field exists in the class
                           	name = atts.getValue(tags.getTagById(FIELD_NAME));
   	                        confirmFieldExists(m_currentClass, name);
  -                     	
  +
                           	String classRef = atts.getValue(tags.getTagById(REFERENCED_CLASS));
                           	try
                           	{
  @@ -341,22 +341,22 @@
   	                        {
   	                            //logger.error(ex);
   	                            throw new MetadataException("Can't find class-ref '" + classRef
+ "' in reference-descriptor '" + name + "'.");
  -	                        }		
  -							
  -                        }						
  -						
  +	                        }
  +
  +                        }
  +
                           break;
                       }
   
                   case COLLECTION_DESCRIPTOR :
                       {
  -                    	
  +
                           if (m_currentClass != null)
                           {
                           	//Confirm that this field exists in the class
  -                        	name = atts.getValue(tags.getTagById(FIELD_NAME));     
  -							confirmFieldExists(m_currentClass, name);	                                     
   
  -	
  +                        	name = atts.getValue(tags.getTagById(FIELD_NAME));
  +							confirmFieldExists(m_currentClass, name);
  +
   	                        String collectionClass = atts.getValue(tags.getTagById(COLLECTION_CLASS));
   	                        //logger.debug("     " + tags.getTagById(Collection_class) + ":
" + collectionClass);
   	                        if (collectionClass != null)
  @@ -370,7 +370,7 @@
   		                        {
   		                            //logger.error(ex);
   		                            throw new MetadataException("Can't find collection-class
'" + collectionClass + "' in collection-descriptor '" + name + "'.");
  -		                        }	
  +		                        }
   	                        }
   	                        // set element-class-ref attribute
   	                        String elementClassRef = atts.getValue(tags.getTagById(ITEMS_CLASS));
  @@ -386,11 +386,11 @@
   		                        {
   		                            //logger.error(ex);
   		                            throw new MetadataException("Can't find element-class-ref
'" + elementClassRef + "' in collection-descriptor '" + name + "'.");
  -		                        }	                        
  +		                        }
   		                     }
  -                        }						
  -						
  -						
  +                        }
  +
  +
                           break;
                       }
   
  @@ -399,26 +399,26 @@
                           // nop
                       }
               }
  -        }  
  +        }
           catch(MetadataException mde)
           {
           	this.m_callingTask.logWarning(" --> Mapping Error: " + mde.getMessage());
           	m_VerifyExceptions.add(mde);
  -        }               
  +        }
           catch(NullPointerException garbage)
           {
  -        	//eat it.		
  +        	//eat it.
           }
           catch(SQLWarning sqlw)
           {
           	this.m_callingTask.logInfo(" --> DB Mapping Warning: " + sqlw.getMessage());
           	m_VerifyWarnings.add(sqlw);
  -        }           
  +        }
           catch(SQLException sqle)
           {
           	this.m_callingTask.logWarning(" --> DB Mapping Error: " + sqle.getMessage());
           	m_VerifyExceptions.add(sqle);
  -        }   
  +        }
           catch (Exception ex)
           {
               logger.error(ex);
  @@ -531,7 +531,7 @@
           }
           catch(Exception ex)
           {
  -        	ex.printStackTrace();		
  +        	ex.printStackTrace();
           }
           throw e;
       }
  @@ -546,8 +546,8 @@
           }
           catch(Exception ex)
           {
  -        	ex.printStackTrace();		
  -        }       
  +        	ex.printStackTrace();
  +        }
           throw e;
       }
   
  @@ -558,7 +558,7 @@
       }
   
       /**
  -     * maps IsolationLevel literals to the corresponding id 
  +     * maps IsolationLevel literals to the corresponding id
        * @param isoLevel
        * @return the id
        */
  @@ -588,19 +588,19 @@
           return defIsoLevel;
       }
   
  -    
  +
       public int getErrorCount()
       {
  -    	return m_VerifyExceptions.size();	
  +    	return m_VerifyExceptions.size();
       }
  -    
  +
       public int getWarningCount()
       {
  -    	return m_VerifyWarnings.size();	
  -    }    
  -    
  +    	return m_VerifyWarnings.size();
  +    }
   
  -	private DBUtility getDBUtility(JdbcConnectionDescriptor jcd) 
  +
  +	private DBUtility getDBUtility(JdbcConnectionDescriptor jcd)
   	throws MetadataException, MalformedURLException, ClassNotFoundException
   	{
   		DBUtility retval = null;
  @@ -609,22 +609,22 @@
   		String password;
   		String url;
   		//if the Tag provided the connection info use that, else
  -		//try to connect with the info in the connectionDescriptor					
  +		//try to connect with the info in the connectionDescriptor
   		if (m_callingTask.hasConnectionInfo())
   		{
   			m_callingTask.logWarning("Using DB conection info from Ant task.");
   			driver = m_callingTask.getJdbcDriver();
   			userName = m_callingTask.getLogon();
   			password = m_callingTask.getPassword();
  -			url = m_callingTask.getUrl();		
  +			url = m_callingTask.getUrl();
   		}
   		else
   		{
   			m_callingTask.logWarning("Using DB conection info from ojb repository connection descriptor.");
   			driver = jcd.getDriver();
   			userName = jcd.getUserName();
  -			password = jcd.getPassWord();	
  -			url = jcd.getProtocol() + ":" + jcd.getSubProtocol() + ":" + jcd.getDbAlias();		
  +			password = jcd.getPassWord();
  +			url = jcd.getProtocol() + ":" + jcd.getSubProtocol() + ":" + jcd.getDbAlias();
   		}
   
   		try
  @@ -633,22 +633,22 @@
   		}
   		catch(MalformedURLException murle)
   		{
  -			throw murle;	
  +			throw murle;
   		}
   		catch(ClassNotFoundException cnfe)
   		{
  -			throw cnfe;	
  +			throw cnfe;
   		}
   		catch (Exception e)
   		{
   			e.printStackTrace();
  -			throw new MetadataException("Could not connect to database with url (" + 
  -			url + "), driver (" + driver + "), logon (" + userName + 
  +			throw new MetadataException("Could not connect to database with url (" +
  +			url + "), driver (" + driver + "), logon (" + userName +
   			"), password (" + password + ").", e);
   		}
   
   		return retval;
  -	}    
  +	}
   
   	private Constructor m_persistConstructor = null;
   	private Constructor getPersistenceClassConstructor() throws NoSuchMethodException
  @@ -660,27 +660,27 @@
   			Class[] aConTypes = new Class[2];
   			aConTypes[0] = Class.class;
   			aConTypes[1] = String.class;
  -			m_persistConstructor = persistentClass.getConstructor(aConTypes);	
  +			m_persistConstructor = persistentClass.getConstructor(aConTypes);
   		}
  -		return m_persistConstructor;	
  +		return m_persistConstructor;
   	}
  -	
  -	protected void confirmFieldExists(Class classToCheck, String fieldName) 
  -	throws MetadataException, NoSuchMethodException, 
  +
  +	protected void confirmFieldExists(Class classToCheck, String fieldName)
  +	throws MetadataException, NoSuchMethodException,
   			InstantiationException, IllegalAccessException
   	{
       	Object[] aConParams = new Object[2];
       	aConParams[0] = classToCheck;
       	aConParams[1] = fieldName;
  -    	
  +
       	try
       	{
       		getPersistenceClassConstructor().newInstance(aConParams);
       	}
       	catch(InvocationTargetException ite)
       	{
  -    		throw new MetadataException(ite.getTargetException().getMessage());	
  -    	}		
  +    		throw new MetadataException(ite.getTargetException().getMessage());
  +    	}
   	}
   
   }
  
  
  

Mime
View raw message