You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by fe...@xybase.com on 2003/05/17 17:31:47 UTC

Problem getting primary key from turbine_user

Hi, I extended the turbine_user by adding a table which uses turbine_user's 
primary key as it's primary key, as shown in schema. This is to obtain 
additional information from new users during account creation phase. All the om 
classes were generated successful using torque. I went on to modify the 
NewAccount.vm and localization files to reflect the added fields. Then I 
attempted to modify the CreateNewUserAndConfirm.java file. Part of the changes 
I made in the doPerform method of this file is shown below. My attempt to get 
the primary key for the newly created user to be inserted into the XPO_USER 
table seems to always return null. I understand that this maybe due to the new 
user row has not been created yet in the turbine user table. Please advise me 
on how to overcome this and also whether my approach of acquiring extra user 
information is valid. Thanks in advance.

security-schema.xml:
  <table name="XPO_USER" idMethod="none">
  	<column name="USER_ID" required="true" primaryKey="true" 
type="INTEGER" />
  	<column name="DESIGNATION" required="true" type="VARCHAR" size="50" />
  	<column name="COMPANY_NAME" required="true" type="VARCHAR" size="99" />
  	
    <foreign-key foreignTable="TURBINE_USER" onDelete="cascade">
      <reference local="USER_ID" foreign="USER_ID"/>
    </foreign-key>
  </table>

CreateNewUserAndConfirm.java :
            if (!accountExists)
            {
                Date now = new Date();

                JetspeedUser user = JetspeedSecurity.getUserInstance();

                user.setUserName( username );
                user.setCreateDate(now);
                user.setLastLogin(new Date(0));
                user.setFirstName( data.getParameters().getString
("firstname") );
                user.setLastName( data.getParameters().getString("lastname") );
                user.setEmail( data.getParameters().getString("email") );

                createUser(user, data);
                
                // create a unique confirmation string for the new user
                String confirmValue = GenerateUniqueId.getIdentifier();

                // allow for disabling of email for configurations without a 
mail server
                boolean newUserNotification = JetspeedResources.getBoolean
("newuser.notification.enable", false);
                boolean newUserApproval = JetspeedResources.getBoolean
("newuser.approval.enable", false);
                boolean enableMail = JetspeedResources.getBoolean
("newuser.confirm.enable", false);
                if (false == enableMail)
                    confirmValue = JetspeedResources.CONFIRM_VALUE;

                if (true == newUserApproval)
                    confirmValue = JetspeedResources.CONFIRM_VALUE_PENDING;

                user.setConfirmed( confirmValue );

                // Store the user object.
                data.setUser(user);

                // XPO additions              
                XpoUser xu = new XpoUser();
                xu.setUserId(Integer.parseInt(user.getUserId()); // Problem here
                xu.setDesignation(data.getParameters().getString
("designation"));
                xu.setCompanyName("test");
                xu.save();

.......







-----------------------------------------------------
This mail sent through IMP: http://webmail.xybase.com

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