portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sg...@apache.org
Subject cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions UpdateAccount.java
Date Tue, 01 May 2001 17:37:08 GMT
sgala       01/05/01 10:37:08

  Modified:    src/java/org/apache/jetspeed/modules/actions
                        UpdateAccount.java
  Log:
  Changed to avoid using the turbine db interface. It only assumes that a
  user implements the User interface, and uses TurbineSecurity service
  to save modifications.
  
  Revision  Changes    Path
  1.10      +32 -72    jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/UpdateAccount.java
  
  Index: UpdateAccount.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/UpdateAccount.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- UpdateAccount.java	2001/04/29 11:58:29	1.9
  +++ UpdateAccount.java	2001/05/01 17:37:07	1.10
  @@ -64,20 +64,17 @@
   import org.apache.turbine.modules.ActionLoader;
   import org.apache.turbine.services.localization.Localization;
   import org.apache.turbine.services.resources.TurbineResources;
  -import org.apache.turbine.services.db.TurbineDB;
  -import org.apache.turbine.util.db.pool.DBConnection;
  +import org.apache.turbine.services.security.TurbineSecurity;
   import org.apache.turbine.util.RunData;
   import org.apache.turbine.util.GenerateUniqueId;
  -import org.apache.turbine.om.security.TurbineUser;
  -import org.apache.turbine.om.security.peer.TurbineUserPeer;
  -import com.workingdogs.village.TableDataSet;
  -import com.workingdogs.village.KeyDef;
  -import com.workingdogs.village.Record;
  +import org.apache.turbine.om.security.User;
   
   /**
  -    Updates an Account in the database. You must have been logged in in order
  -    to update the account.
  -*/
  + *
  + *   Updates an Account in the User and save the User object to backing store.
  + *   You must have been logged in in order
  + *   to update the account.
  + */
   public class UpdateAccount extends Action
   {
       public void doPerform( RunData data ) throws Exception
  @@ -163,77 +160,40 @@
           }
           
   
  -        // UPDATA DATA IN DB
  -        //
  -        // get a connection to the db
  -        DBConnection db = TurbineDB.getConnection();
  -        Connection connection = db.getConnection();
  -
  -        // execute the query
  -        KeyDef kd = new KeyDef().addAttrib(TurbineUserPeer.USER_ID);
  -        TableDataSet tds = null;
  -        try
  -        {
  -            // find the user information
  -            tds = new TableDataSet(connection, TurbineUserPeer.getTableName(), kd );
  -            tds.where ( TurbineUserPeer.USER_ID + " = " + ((TurbineUser)data.getUser()).getPrimaryKey()
);
  -            tds.fetchRecords(1);
  -            if ( tds.size() == 1 )
  +        String currentEmail = (String) data.getUser().getEmail();
  +        if ( currentEmail == null || ! currentEmail.equalsIgnoreCase(email) )
               {
  -                Record rec = tds.getRecord(0);
  -                // update the record values
  -                if ( changepass ) rec.setValue("PASSWORD_VALUE", password );
  -                rec.setValue("FIRST_NAME", firstname );
  -                rec.setValue("LAST_NAME", lastname );
  -
  -                // if the email addresses are different, then require the user to confirm
again
  -                String currentEmail = (String) data.getUser().getPerm(TurbineUserPeer.EMAIL);
  -                if ( currentEmail == null || ! currentEmail.equalsIgnoreCase(email) )
  -                {
  -                    rec.setValue("EMAIL", email );
  -                    rec.setValue("CONFIRM_VALUE", GenerateUniqueId.getIdentifier() );
  -                    rec.save();
  -                    
  -                    ActionLoader.getInstance().exec(data, "SendConfirmationEmail");
  -                    // add in the username to the parameters because ConfirmRegistration
needs it
  -                    data.getParameters().add("username", data.getUser().getUserName() );
  -                    data.setMessage(Localization.getString("UPDATEACCOUNT_NEWEMAILCONFIRM"));
  -                    data.setScreenTemplate("ConfirmRegistration");
  -                }
  -                else
  -                {       
  -                    rec.save();
  -                }
  -            
  -                // update currently logged in information that might have changed
  -                data.getUser().setPerm(TurbineUserPeer.FIRST_NAME, firstname);
  -                data.getUser().setPerm(TurbineUserPeer.LAST_NAME, lastname);
  -                data.getUser().setPerm(TurbineUserPeer.EMAIL, email);
  -                if ( changepass ) {
  -                    data.getUser().setPerm(TurbineUserPeer.PASSWORD, password);
  -                    // Save to TurbineUser object as well (fix by Jay Turpin)
  -                    data.getUser().setPassword(password);
  -                }
  -
  -                data.setMessage (Localization.getString("UPDATEACCOUNT_DONE"));
  +                //Send confirmation email if different than current
  +                data.getUser().setEmail( email );
  +                data.getUser().setConfirmed( GenerateUniqueId.getIdentifier() );
  +                TurbineSecurity.saveUser( data.getUser() );
  +                ActionLoader.getInstance().exec(data, "SendConfirmationEmail");
  +                // add in the username to the parameters because ConfirmRegistration needs
it
  +                data.getParameters().add("username", data.getUser().getUserName() );
  +                data.setMessage(Localization.getString("UPDATEACCOUNT_NEWEMAILCONFIRM"));
  +                data.setScreenTemplate("ConfirmRegistration");
               }
  -            else
  -            {
  -                data.setMessage(Localization.getString("UPDATEACCOUNT_NOUSER"));
  -                data.setScreenTemplate("Login");
  +        else
  +            {       
  +                TurbineSecurity.saveUser( data.getUser() );
               }
  -        }
  -        finally
  -        {
  -            if ( tds != null ) tds.close();
  -            TurbineDB.releaseConnection(db);
  +            
  +        // update currently logged in information that might have changed
  +        data.getUser().setFirstName( firstname );
  +        data.getUser().setLastName( lastname );
  +        data.getUser().setEmail( email );
  +        if ( changepass ) {
  +            data.getUser().setPassword(password);
           }
  +        TurbineSecurity.saveUser( data.getUser() );
  +        data.setMessage (Localization.getString("UPDATEACCOUNT_DONE"));
           
       }
       
       private void backToEditAccount( RunData rundata, Hashtable screenData )
       {   
  -        rundata.getRequest().setAttribute( "ScreenDataEditAccount", screenData );
  +        rundata.getRequest().setAttribute( "ScreenDataEditAccount",
  +                                           screenData );
           rundata.setScreenTemplate("EditAccount");
       }
   
  
  
  

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


Mime
View raw message