jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jalka...@apache.org
Subject svn commit: r667783 - /incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/XMLUserDatabase.java
Date Sat, 14 Jun 2008 12:29:26 GMT
Author: jalkanen
Date: Sat Jun 14 05:29:26 2008
New Revision: 667783

URL: http://svn.apache.org/viewvc?rev=667783&view=rev
Log:
Fix: Would reject all new users

Modified:
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/XMLUserDatabase.java

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/XMLUserDatabase.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/XMLUserDatabase.java?rev=667783&r1=667782&r2=667783&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/XMLUserDatabase.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/XMLUserDatabase.java Sat Jun 14
05:29:26 2008
@@ -513,26 +513,20 @@
         String index = profile.getLoginName();
         NodeList users = c_dom.getElementsByTagName( USER_TAG );
         Element user = null;
-        boolean isNew = true;
         for( int i = 0; i < users.getLength(); i++ )
         {
             Element currentUser = (Element) users.item( i );
             if ( currentUser.getAttribute( LOGIN_NAME ).equals( index ) )
             {
                 user = currentUser;
-                isNew = false;
                 break;
             }
         }
         
-        // If user not found, somebody's been deleting/modifying users behind our back
-        if ( user == null )
-        {
-            throw new IllegalStateException( "UserDatabase did not contain user with loginName="
+ profile.getLoginName() + "!" );
-        }
+        boolean isNew = false;
         
         Date modDate = new Date( System.currentTimeMillis() );
-        if ( isNew )
+        if( user == null )
         {
             // Create new user node
             profile.setCreated( modDate );
@@ -540,16 +534,18 @@
             user = c_dom.createElement( USER_TAG );
             c_dom.getDocumentElement().appendChild( user );
             setAttribute( user, CREATED, c_format.format( profile.getCreated() ) );
+            isNew = true;
         }
         else
         {
             // To update existing user node, delete old attributes first...
-            NodeList artributes = user.getElementsByTagName( ATTRIBUTES_TAG );
-            for ( int i = 0; i < artributes.getLength(); i++ )
+            NodeList attributes = user.getElementsByTagName( ATTRIBUTES_TAG );
+            for ( int i = 0; i < attributes.getLength(); i++ )
             {
-                user.removeChild( artributes.item( i ) );
+                user.removeChild( attributes.item( i ) );
             }
         }
+        
         setAttribute( user, LAST_MODIFIED, c_format.format( modDate ) );
         setAttribute( user, LOGIN_NAME, profile.getLoginName() );
         setAttribute( user, FULL_NAME, profile.getFullname() );



Mime
View raw message