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 Pierre Henry <ph...@proconcept.ch> on 2002/11/15 13:57:33 UTC
Using my extended JetspeedUser
Hi all,
I am trying to use an existing table instead of the default TURBINE_USER
table to store my user data.
I already went through the following steps successfuly :
1. Modify the torque schema.xml :
I changed the name of the table user to MYUSER, but I specified
JavaName=TurbineUser, so that the generated classes keeps the same name.
Added the 'title' field.
I rebuilt to generate the peer classes.
2. Create a MyUser interface and a MyUserImpl class
MyUser extends JetspeedUser and add the setTitle and getTitle methods, and
the static final String TITLE = "title".
MyUserImpl extends BaseJetspeedUser and implements MyUser :
public class MyUserImpl extends BaseJetspeedUser implements MyUser {
public String getTitle(){
return (String) getPerm(MyUser.TITLE);
}
public void setTitle(String title){
setPerm(PcsUser.TITLE, title);
}
}
2. Modifiy the JetspeedSecurity.* files
services.JetspeedSecurity.user.class=myclasses.portal.om.security.MyUserImpl
Wherever this parameter appears.
3. Now I wanted to test this new field by modifying MyHelloUserPortlet
(portlet from tutorial).
I added the code :
....
MyUser user = (MyUser)runData.getUser();
String title = user.getTitle();
if(title==null)
{
user.setTitle(title="Mister");
}
....
This worked fine, except that the new title value (by now all my title
fields are empty) was not saved in the db.
So i added the following line to try and force the saving
try
{
JetspeedUserManagement.saveUser(user);
}
catch(Exception e)
{
System.out.println("Problem by saving user : "+e.toString());
}
But now the portlet doesn't display anymore and here is the output :
Problem by saving user :
org.apache.jetspeed.services.security.UserException: Failed to save user
object : No changes to save
Obviously, the saveUser method sees the user as a BaseJetspeedUser and not
as a MyUser, and therefore can't see the changes.
What should I change ?
Should I extend the TurbineUserManagement to cast the user to MyUser ? Or
did I miss something ?
Any help appreciated !
I hope the first 3 steps can help...
Pierre