KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > base > secureApp > VariablesSecureApp


1 /*
2  ************************************************************************************
3  * Copyright (C) 2001-2006 Openbravo S.L.
4  * Licensed under the Apache Software License version 2.0
5  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6  * Unless required by applicable law or agreed to in writing, software distributed
7  * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8  * CONDITIONS OF ANY KIND, either express or implied. See the License for the
9  * specific language governing permissions and limitations under the License.
10  ************************************************************************************
11 */

12 package org.openbravo.base.secureApp;
13
14 import org.openbravo.base.VariablesBase;
15 import javax.servlet.http.*;
16 import org.openbravo.erpCommon.utility.OBError;
17 import org.openbravo.data.FieldProvider;
18
19 public class VariablesSecureApp extends VariablesBase {
20   private String JavaDoc user;
21   private String JavaDoc role;
22   private String JavaDoc language;
23   private String JavaDoc theme;
24   private String JavaDoc client;
25   private String JavaDoc organization;
26   private String JavaDoc warehouse;
27   private String JavaDoc command;
28   private String JavaDoc userClient;
29   private String JavaDoc userOrganization;
30   private String JavaDoc dbSessionID;
31   private String JavaDoc javaDateFormat;
32   private String JavaDoc jsDateFormat;
33   private String JavaDoc sqlDateFormat;
34
35   public VariablesSecureApp(String JavaDoc strUser, String JavaDoc strClient, String JavaDoc strOrganization) {
36     this.user = strUser;
37     this.role = "";
38     this.language = System.getProperty("user.language") + "_" + System.getProperty("user.country");
39     this.theme = "";
40     this.client = strClient;
41     this.organization = strOrganization;
42     this.userClient = "";
43     this.userOrganization = "";
44     this.warehouse = "";
45     this.dbSessionID = "";
46     this.command = "DEFAULT";
47     this.javaDateFormat = "";
48     this.jsDateFormat = "";
49     this.sqlDateFormat = "";
50   }
51
52   public VariablesSecureApp(HttpServletRequest request) {
53     super(request);
54     this.user = getSessionValue("#AD_User_ID");
55     this.role = getSessionValue("#AD_Role_ID");
56     this.language = getSessionValue("#AD_Language");
57     this.theme = getSessionValue("#Theme");
58     this.client = getSessionValue("#AD_Client_ID");
59     this.organization = getSessionValue("#AD_Org_ID");
60     this.userClient = getSessionValue("#User_Client");
61     this.userOrganization = getSessionValue("#User_Org");
62     this.warehouse = getSessionValue("#M_Warehouse_ID");
63     this.dbSessionID = getSessionValue("#AD_Session_ID");
64     this.command = getStringParameter("Command", "DEFAULT");
65     this.javaDateFormat = getSessionValue("#AD_JavaDateFormat");
66     this.jsDateFormat = getSessionValue("#AD_JsDateFormat");
67     this.sqlDateFormat = getSessionValue("#AD_SqlDateFormat");
68   }
69
70   public String JavaDoc getUser() {
71     return user;
72   }
73
74   public String JavaDoc getRole() {
75     return role;
76   }
77
78   public String JavaDoc getLanguage() {
79     return language;
80   }
81
82   public String JavaDoc getTheme() {
83     return theme;
84   }
85
86   public String JavaDoc getClient() {
87     return client;
88   }
89
90   public String JavaDoc getOrg() {
91     return organization;
92   }
93
94   public String JavaDoc getUserClient() {
95     return userClient;
96   }
97
98   public String JavaDoc getUserOrg() {
99     return userOrganization;
100   }
101
102   public String JavaDoc getWarehouse() {
103     return warehouse;
104   }
105
106   public String JavaDoc getDBSession() {
107     return dbSessionID;
108   }
109
110   public String JavaDoc getCommand() {
111     return command;
112   }
113
114   public boolean commandIn(String JavaDoc inKey1) {
115     if (command.equals(inKey1))
116       return true;
117     else
118       return false;
119   }
120
121   public boolean commandIn(String JavaDoc inKey1, String JavaDoc inKey2) {
122     if (command.equals(inKey1) || command.equals(inKey2))
123       return true;
124     else
125       return false;
126   }
127
128   public boolean commandIn(String JavaDoc inKey1, String JavaDoc inKey2, String JavaDoc inKey3) {
129     if (command.equals(inKey1) || command.equals(inKey2) || command.equals(inKey3))
130       return true;
131     else
132       return false;
133   }
134
135   public boolean commandIn(String JavaDoc inKey1, String JavaDoc inKey2, String JavaDoc inKey3, String JavaDoc inKey4) {
136     if (command.equals(inKey1) || command.equals(inKey2) || command.equals(inKey3) || command.equals(inKey4))
137       return true;
138     else
139       return false;
140   }
141   
142   public boolean commandIn(String JavaDoc inKey1, String JavaDoc inKey2, String JavaDoc inKey3, String JavaDoc inKey4, String JavaDoc inKey5) {
143     if (command.equals(inKey1) || command.equals(inKey2) || command.equals(inKey3) || command.equals(inKey4) || command.equals(inKey5))
144       return true;
145     else
146       return false;
147   }
148
149   public String JavaDoc getJavaDateFormat() {
150     return javaDateFormat;
151   }
152   public String JavaDoc getJsDateFormat() {
153     return jsDateFormat;
154   }
155   public String JavaDoc getSqlDateFormat() {
156     return sqlDateFormat;
157   }
158
159   public OBError getMessage(String JavaDoc AD_Tab_ID) {
160     return ((OBError)getSessionObject(AD_Tab_ID + "|message"));
161   }
162
163   public void setMessage(String JavaDoc AD_Tab_ID, OBError error) {
164     setSessionObject(AD_Tab_ID + "|message", error);
165   }
166
167   public void removeMessage(String JavaDoc AD_Tab_ID) {
168     removeSessionValue(AD_Tab_ID + "|message");
169   }
170   
171   public FieldProvider getEditionData(String JavaDoc AD_Tab_ID) {
172     return ((FieldProvider)getSessionObject(AD_Tab_ID + "|editionData"));
173   }
174
175   public void setEditionData(String JavaDoc AD_Tab_ID, FieldProvider data) {
176     setSessionObject(AD_Tab_ID + "|editionData", data);
177   }
178
179   public void removeEditionData(String JavaDoc AD_Tab_ID) {
180     removeSessionValue(AD_Tab_ID + "|editionData");
181   }
182 }
183
Popular Tags