db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r589804 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/conn/ iapi/util/ impl/db/ impl/sql/conn/
Date Mon, 29 Oct 2007 18:49:46 GMT
Author: djd
Date: Mon Oct 29 11:49:45 2007
New Revision: 589804

URL: http://svn.apache.org/viewvc?rev=589804&view=rev
Log:
DERBY-3147 (partial) Clean of handling user identifiers and renaming some IdUtil methods with
comments to make behaviour clearer.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/IdUtil.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericAuthorizer.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java?rev=589804&r1=589803&r2=589804&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
Mon Oct 29 11:49:45 2007
@@ -94,11 +94,10 @@
 	/**
 	 * Initialize. For use after pushing the contexts that initialization needs.
 	 *
-	 * @param sqlConnection	Whether or not this is called from a sql connection.
 	 *
 	 * @exception StandardException thrown if something goes wrong
 	 */
-	void initialize(boolean sqlConnection) throws StandardException;
+	void initialize() throws StandardException;
 
 	/**
 	 * Get value of logStatementText.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/IdUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/IdUtil.java?rev=589804&r1=589803&r2=589804&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/IdUtil.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/util/IdUtil.java Mon Oct 29 11:49:45
2007
@@ -129,11 +129,7 @@
 	}
 
     /**
-      Parse a multi-part (dot separated) SQL identifier form the
-      StringReader provided. Raise an excepion
-      if the string does not contain valid SQL indentifiers.
-      The returned String array contains the normalized form of the
-      identifiers.
+c
     
     @param s The string to be parsed
     @return An array of strings made by breaking the input string at its dots, '.'.
@@ -169,16 +165,14 @@
 	}
 	
 	/**
-	  Convert the String provided to an ID. Throw an exception
-	  iff the string does not contain only a valid external form
-	  for an id. This is a convenience routine that simply
-	  uses getId(StringReader) to do the work.
-	  
-	  <P> See the header for getId below for restrictions.
-	  
+      Parse a SQL identifier from the String provided. Raise an excepion
+      if the string does not contain a valid SQL indentifier.
+      The returned String  contains the normalized form of the
+      identifier.
+        
 	  @exception StandardException Oops
 	  */
-	public static String parseId(String s)
+	public static String parseSQLIdentifier(String s)
 		 throws StandardException
 	{
 		StringReader r = new StringReader(s);
@@ -400,8 +394,10 @@
 
 
 	/**
-	  Scan a list of ids from the string provided. This returns
-	  an array with id per entry. This raises an an exception if
+	  Scan a list of comma separated SQL identifiers from the string provided.
+      This returns an array with containing the normalized forms of the identifiers.
+      
+      This raises an an exception if
 	  the string does not contain a valid list of names.
 
 	  @exception StandardException Oops
@@ -418,7 +414,8 @@
 	
 	
 	/**
-	  Parse an idList. 
+	  Parse a list of comma separated SQL identifiers returning
+      them a as elements in an array.
 
 	  @param normalize true means return ids in nomral form, false means
 	        return them as they were entered.
@@ -497,7 +494,7 @@
 	}
 
 	/**
-	 * Map userName to authorizationId
+	 * Map userName to authorizationId in its normal form.
 	 * 
 	 * @exception StandardException on error or userName is null
 	 */
@@ -505,7 +502,7 @@
 	{
 		try {
             if (userName != null)
-			    return parseId(userName);
+			    return parseSQLIdentifier(userName);
 		}
 		catch (StandardException se) {
 		}
@@ -619,7 +616,8 @@
 	}
 
 	/**
-	  Return true if the id provided is on the list provided.
+	  Return true if the normalized value of an indentifier is on the list 
+      of SQL identifiers provided.
 	  @param id an id in normal form
 	  @param	list a list of ids in external form.
 	  @exception StandardException oops.
@@ -635,13 +633,18 @@
 	}
 
 	/**
-	  Delete an id from a list of ids.
+	  Delete an normal value from a list of SQL identifiers.
+      The returned list maintains its remaining identifiers in the
+      format they were upon entry to the call.
+      
+      
 	  @param id an id in normal form (quotes removed, upshifted if regular)
 	  @param list a comma separated list of ids in external
 	         form (possibly delmited or not upshifted).
 	  @return the list with the id deleted or null if the
 	    resulting list has no ids. If 'id' is not on 'list'
-		this returns list unchanged.
+		this returns list unchanged. If list becomes empty after the removal
+        null is returned.
 				 
 	  @exception StandardException oops.
 	  */
@@ -652,13 +655,14 @@
 		Vector v = new Vector();
 		StringReader r = new StringReader(list);
 		String[] enteredList_a = parseIdList(r,false);
+        
 		//
 		//Loop through enteredList element by element
 		//removing elements that match id. Before we
-		//compare we parse each id in list to convert
+		//compare we parse each SQL indentifier in list to convert
 		//to normal form.
 		for (int ix=0; ix < enteredList_a.length; ix++)
-			if (!id.equals(IdUtil.parseId(enteredList_a[ix])))
+			if (!id.equals(IdUtil.parseSQLIdentifier(enteredList_a[ix])))
 				v.addElement(enteredList_a[ix]);
 		if (v.size() == 0)
 			return null;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java?rev=589804&r1=589803&r2=589804&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java Mon Oct 29
11:49:45 2007
@@ -318,7 +318,7 @@
 		//Initialize our language connection context. Note: This is
 		//a bit of a hack. Unfortunately, we can't initialize this
 		//when we push it. We first must push a few more contexts. 
-		lctx.initialize(true);		
+		lctx.initialize();		
 
 		// Need to commit this to release locks gotten in initialize.  
 		// Commit it but make sure transaction not have any updates. 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericAuthorizer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericAuthorizer.java?rev=589804&r1=589803&r2=589804&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericAuthorizer.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericAuthorizer.java
Mon Oct 29 11:49:45 2007
@@ -64,17 +64,13 @@
 	private final String authorizationId; //the userName after parsing by IdUtil 
 	
 	GenericAuthorizer(String authorizationId, 
-						     LanguageConnectionContext lcc,
-					         boolean sqlConnection)
+						     LanguageConnectionContext lcc)
 		 throws StandardException
 	{
 		this.lcc = lcc;
 		this.authorizationId = authorizationId;
 
-		//we check the access level only if this is coming from a sql
-		//connection, not internal logSniffer or StageTrunc db connection
-		if(sqlConnection)
-			refresh();
+		refresh();
 	}
 
 	/*

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?rev=589804&r1=589803&r2=589804&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
Mon Oct 29 11:49:45 2007
@@ -307,16 +307,11 @@
 		triggerTables = new ArrayList();
 	}
 
-	public void initialize(boolean sqlConnection) throws StandardException
+	public void initialize() throws StandardException
 	{
 		//
 		//Creating the authorizer authorizes the connection.
-		authorizer = new GenericAuthorizer(IdUtil.getUserAuthorizationId(userName),this, sqlConnection);
-
-		//we can ignore the following if this is a database connection
-		//associated with internal thread such as logSniffer and StageTrunc
-		if(!sqlConnection)
-			return;
+		authorizer = new GenericAuthorizer(IdUtil.getUserAuthorizationId(userName),this);
 
 		/*
 		** Set the authorization id.  User shouldn't



Mime
View raw message