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 "Doherty, Sean" <se...@xelus.com> on 2003/11/18 20:34:00 UTC

RE: Question on Extending the BaseJetspeedUser Object in Jetspeed 1.4

You need to update the JetspeedSecurity.properties file to specify your
class as the User class.  Specifically, you need to update the
"services.JetspeedSecurity.user.class" property.

You may also need to provide your own implementation of the UserManagement
class if your UnifocusUser class needs additional initialization.

Regards,
Sean

-----Original Message-----
From: Celeste Haseltine [mailto:CHaseltine@unifocus.com]
Sent: Tuesday, November 18, 2003 2:28 PM
To: 'Jetspeed Users List'
Subject: Question on Extending the BaseJetspeedUser Object in Jetspeed
1.4


I'm having a problem extending the BaseJetspeedUser class to handle
additional fields that we need to add to the Turbine User table.  Bottom
line, how do I go about accessing this custom object in a portlet?  If I
cast the TurbineUser object returned by the method runData.getUser() to my
UnifocusUser object in a AbstractInstancePortlet portlet, I get a run time
class cast exception, as I would expect.  I thought I would post this and
see if anyone can advise me on exactly where/how I am suppose to use my
custom User object in Jetspeed.  

To create my custom User class (UnifocusUser), I did the following per the
web site and the BaseJetspeedUser API:

Added the new columns in my table to build/torque/security_schema.xml
Modified the build/torque/build.properties file to generate DDL for
SQLServer 2000
Rebuilt Jetspeed 1.4 source to generate the OM objects.
Extended class BaseJetspeedUser to create UnifocusUser, per the
BaseJetspeedUser API.

My UnifocusUser object is as follows:

public class UnifocusUser extends BaseJetspeedUser {
	
	public void setWebLoginID(String ID){
			setPerm("WEBLOGINID",ID);			
	}//end method
	
	public String getWebLoginID(){
		return (String) getPerm("WEBLOGINID");
	}//end method

}//end class definition

So far so good.  The problem comes in trying to figure out how to use this
class in a portlet.  If my understanding of Jetspeed is correct, the object
returned by the runData.getUser() method is a TurbineUser object.  So
exactly how do I utilize this UnifocusUser object in my own portlets?

Here is the test portlet I used to verify that I could access the additional
fields I added to the TurbineUser table:

public class PortletTestUnifocusUser extends AbstractInstancePortlet{

	public ConcreteElement getContent(RunData runData)
	{
		StringBuffer text =new StringBuffer();
		text.append("Hello ");
		
		//THIS WORKS, I CAN ACCESS THE ADDED FIELD.
		String ID = (String)runData.getUser().getPerm("WEBLOGINID");
		
		//THIS DOES NOT WORK, CLASS CAST EXCEPTION, AS EXPECTED 
		//UnifocusUser user = (UnifocusUser) runData.getUser();
		//String ID = user.getWebLoginID();
		
		String name  = runData.getUser().getFirstName();
		if (name ==null)
			name =" Anonymous";
		text.append (name);
		text.append ("!");
		text.append ("  Your ID is " + ID);
		return (new StringElement(text.toString()));
	}//end method

}//end class definition

What am I missing here?  Any advice would be greatly appreciated!!!

Celeste


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