1/*2 * Copyright 2000-2001,2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.modules.actions;
181920// JDK Stuff21import java.util.*;
2223// External Stuff24import org.apache.turbine.modules.Action;
25import org.apache.turbine.services.resources.TurbineResources;
2627import org.apache.turbine.util.RunData;
28import org.apache.jetspeed.om.security.JetspeedUser;
29import org.apache.jetspeed.services.JetspeedSecurity;
3031publicclassPrepareScreenEditAccountextends Action
32 {
33publicvoid doPerform( RunData rundata ) throws Exception
34 {
35// check to make sure the user has logged in before accessing this screen36if ( ! rundata.getUser().hasLoggedIn() )
37 {
38 rundata.setScreenTemplate( TurbineResources.getString( "services.JspService.screen.error.NotLoggedIn","Error") );
39return;
40 }
4142// fill in the blanks in the form43 String username = rundata.getUser().getUserName();
44 String firstname = null;
45 String lastname = null;
46 String email = null;
4748// for security, get information about the user from the database49// instead of what we already have cached.50try51 {
52JetspeedUser user = JetspeedSecurity.getUser(rundata.getUser().getUserName());
53 firstname = (String) user.getFirstName();
54 lastname = (String) user.getLastName();
55 email = (String) user.getEmail();
5657if ( firstname == null )
58 firstname = "";
59if ( lastname == null )
60 lastname = "";
61if ( email == null )
62 email = "";
6364 Hashtable screenData = new Hashtable();
65 screenData.put( "username", username );
66 screenData.put( "firstname", firstname );
67 screenData.put( "lastname", lastname );
68 screenData.put( "email", email );
69 rundata.getRequest().setAttribute( "ScreenDataEditAccount", screenData );
7071return;
72 }
73catch(Exception e)
74 {
75 rundata.setScreenTemplate( TurbineResources.getString( "services.JspService.screen.error.NotLoggedIn","Error") );
76return;
77 }
78 }
79 }