KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > modules > actions > PrepareScreenEditAccount


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 at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * 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 and
14  * limitations under the License.
15  */

16
17 package org.apache.jetspeed.modules.actions;
18
19
20 // JDK Stuff
21
import java.util.*;
22
23 // External Stuff
24
import org.apache.turbine.modules.Action;
25 import org.apache.turbine.services.resources.TurbineResources;
26
27 import org.apache.turbine.util.RunData;
28 import org.apache.jetspeed.om.security.JetspeedUser;
29 import org.apache.jetspeed.services.JetspeedSecurity;
30
31 public class PrepareScreenEditAccount extends Action
32 {
33     public void doPerform( RunData rundata ) throws Exception JavaDoc
34     {
35         // check to make sure the user has logged in before accessing this screen
36
if ( ! rundata.getUser().hasLoggedIn() )
37         {
38             rundata.setScreenTemplate( TurbineResources.getString( "services.JspService.screen.error.NotLoggedIn","Error") );
39             return;
40         }
41         
42         // fill in the blanks in the form
43
String JavaDoc username = rundata.getUser().getUserName();
44         String JavaDoc firstname = null;
45         String JavaDoc lastname = null;
46         String JavaDoc email = null;
47
48         // for security, get information about the user from the database
49
// instead of what we already have cached.
50
try
51         {
52             JetspeedUser user = JetspeedSecurity.getUser(rundata.getUser().getUserName());
53             firstname = (String JavaDoc) user.getFirstName();
54             lastname = (String JavaDoc) user.getLastName();
55             email = (String JavaDoc) user.getEmail();
56         
57             if ( firstname == null )
58                 firstname = "";
59             if ( lastname == null )
60                 lastname = "";
61             if ( email == null )
62                 email = "";
63
64             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 );
70     
71             return;
72         }
73         catch(Exception JavaDoc e)
74         {
75             rundata.setScreenTemplate( TurbineResources.getString( "services.JspService.screen.error.NotLoggedIn","Error") );
76             return;
77         }
78     }
79 }
80
Popular Tags