1 /*
2 * Replica is published under the terms
3 * of the Apache Software License.
4 */
5 package replica.server.commands;
6
7 import replica.core.*;
8 import replica.core.ApplicationMessage;
9
10 /***
11 * This command is extended by all server commands that require that the
12 * user is logged in.
13 *
14 * @author Pedro Costa
15 * @author Helder Silva
16 * @since 20/Jan/2004
17 */
18 public abstract class LoggedInCommand extends ApplicationCommand {
19
20 /***
21 *
22 */
23 public LoggedInCommand() {
24 super();
25 }
26
27 /* (non-Javadoc)
28 * @see replica.server.commands.ServerCommand#execute(replica.server.ServerCommandVO)
29 */
30 protected Object execute(ApplicationMessage arg) {
31
32 if( isLoggedIn(arg) ){
33 return internalExecute(arg);
34 }
35
36 return "Not Logged In.";
37 }
38
39 /***
40 * Checks that the user is logged in.
41 *
42 * @param arg
43 * @return
44 */
45 protected boolean isLoggedIn(ApplicationMessage arg ){
46
47 return getSessionManager().getSession(arg.getSessionID()).isLoggedIn();
48 }
49
50 protected abstract Object internalExecute(ApplicationMessage arg);
51 }
This page was automatically generated by Maven