KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > core > session > BaseSession


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11  * the license for the specific language governing your rights and limitations.
12  *
13  * @created Jul 23, 2005
14  * @author James Dixon
15  *
16  */

17
18 package org.pentaho.core.session;
19
20 import java.util.Locale JavaDoc;
21
22 import org.pentaho.core.audit.AuditHelper;
23 import org.pentaho.core.audit.MessageTypes;
24 import org.pentaho.core.system.PentahoBase;
25 import org.pentaho.messages.Messages;
26 import org.pentaho.util.logging.ILogger;
27
28 public abstract class BaseSession extends PentahoBase implements IPentahoSession {
29
30     
31     private String JavaDoc name;
32
33     private String JavaDoc id;
34
35     private String JavaDoc processId;
36
37     private String JavaDoc actionName;
38
39     private Locale JavaDoc locale;
40
41     private boolean authenticated;
42     
43     private volatile boolean backgroundExecutionAlert;
44     
45     public BaseSession(String JavaDoc name, String JavaDoc id, Locale JavaDoc locale) {
46         this.name = name;
47         this.id = id;
48         this.locale = locale;
49         actionName = ""; //$NON-NLS-1$
50
setLogId( Messages.getString("BaseSession.CODE_LOG_ID", id, ILogger.SESSION_LOG, name) ); //$NON-NLS-1$
51
AuditHelper.audit(id, name, actionName, getObjectName(), "", MessageTypes.SESSION_START, "", "", null, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
52
authenticated = false;
53     }
54
55     public boolean isAuthenticated() {
56         return authenticated;
57     }
58
59     public void setAuthenticated(String JavaDoc name) {
60         if (name != null) {
61             authenticated = true;
62             this.name = name;
63         }
64     }
65
66     public void setNotAuthenticated() {
67         name = null;
68         authenticated = false;
69     }
70
71     public Locale JavaDoc getLocale() {
72         return locale;
73     }
74
75     public void destroy() {
76       AuditHelper.audit(id, name, actionName, getObjectName(), "", MessageTypes.SESSION_END, "", "", null, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
77
}
78
79     public void setActionName(String JavaDoc actionName) {
80         this.actionName = actionName;
81     }
82
83     public void setProcessId(String JavaDoc processId) {
84         this.processId = processId;
85     }
86
87     /*
88      * (non-Javadoc)
89      *
90      * @see org.pentaho.core.session.IPentahoSession#getName()
91      */

92     public String JavaDoc getName() {
93         return name;
94     }
95
96     /*
97      * (non-Javadoc)
98      *
99      * @see org.pentaho.audit.IAuditable#getId()
100      */

101     public String JavaDoc getId() {
102         return id;
103     }
104
105     /*
106      * (non-Javadoc)
107      *
108      * @see org.pentaho.audit.IAuditable#getObjectName()
109      */

110     public String JavaDoc getObjectName() {
111         return this.getClass().getName();
112     }
113
114     /*
115      * (non-Javadoc)
116      *
117      * @see org.pentaho.audit.IAuditable#getProcessId()
118      */

119     public String JavaDoc getProcessId() {
120         return processId;
121     }
122
123     /*
124      * (non-Javadoc)
125      *
126      * @see org.pentaho.audit.IAuditable#getActionName()
127      */

128     public String JavaDoc getActionName() {
129         return actionName;
130     }
131     
132     public synchronized void setBackgroundExecutionAlert() {
133       this.backgroundExecutionAlert = true;
134     }
135     
136     public synchronized boolean getBackgroundExecutionAlert() {
137       return this.backgroundExecutionAlert;
138     }
139     
140     public synchronized void resetBackgroundExecutionAlert() {
141       this.backgroundExecutionAlert = false;
142     }
143     
144 }
145
Popular Tags