1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.waarp.gateway.kernel.session;
21
22 import io.netty.handler.codec.http.HttpMethod;
23 import org.waarp.common.command.exception.CommandAbstractException;
24 import org.waarp.common.file.DirInterface;
25 import org.waarp.common.file.FileParameterInterface;
26 import org.waarp.common.file.Restart;
27 import org.waarp.common.file.SessionInterface;
28 import org.waarp.common.file.filesystembased.FilesystemBasedOptsMLSxImpl;
29 import org.waarp.gateway.kernel.HttpPage.PageRole;
30 import org.waarp.gateway.kernel.commonfile.CommonDirImpl;
31 import org.waarp.gateway.kernel.commonfile.FilesystemBasedFileParameterImpl;
32 import org.waarp.gateway.kernel.database.DbConstantGateway;
33
34
35
36
37 public class HttpSession implements SessionInterface {
38 protected HttpAuthInterface httpAuth;
39 protected long logid = DbConstantGateway.ILLEGALVALUE;
40 protected CommonDirImpl dir;
41 HttpMethod method;
42 private String cookieSession;
43 private PageRole currentCommand;
44 protected String filename;
45
46
47
48
49 public HttpSession() {
50
51 }
52
53
54
55
56 public final HttpMethod getMethod() {
57 return method;
58 }
59
60
61
62
63 public final void setMethod(final HttpMethod method) {
64 this.method = method;
65 }
66
67
68
69
70 public final void setHttpAuth(final HttpAuthInterface httpAuth) {
71 this.httpAuth = httpAuth;
72 dir = new CommonDirImpl(this, new FilesystemBasedOptsMLSxImpl());
73 try {
74 dir.changeDirectoryNotChecked(httpAuth.getUser());
75 dir.changeDirectoryNotChecked(httpAuth.getAccount());
76 } catch (final CommandAbstractException ignored) {
77
78 }
79 }
80
81 @Override
82 public final HttpAuthInterface getAuth() {
83 return httpAuth;
84 }
85
86 @Override
87 public final void clear() {
88 if (httpAuth != null) {
89 httpAuth.clear();
90 }
91 }
92
93 @Override
94 public final int getBlockSize() {
95 return 8192;
96 }
97
98 @Override
99 public final FileParameterInterface getFileParameter() {
100 return FilesystemBasedFileParameterImpl.fileParameterInterface;
101 }
102
103 @Override
104 public final Restart getRestart() {
105 return null;
106 }
107
108 @Override
109 public final String getUniqueExtension() {
110 return ".postu";
111 }
112
113
114
115
116 public final long getLogid() {
117 return logid;
118 }
119
120
121
122
123 public final void setLogid(final long logid) {
124 this.logid = logid;
125 }
126
127 @Override
128 public final DirInterface getDir() {
129 return dir;
130 }
131
132
133
134
135 public final PageRole getCurrentCommand() {
136 return currentCommand;
137 }
138
139
140
141
142 public final void setCurrentCommand(final PageRole currentCommand) {
143 this.currentCommand = currentCommand;
144 }
145
146
147
148
149 public final String getCookieSession() {
150 return cookieSession;
151 }
152
153
154
155
156 public final void setCookieSession(final String cookieSession) {
157 this.cookieSession = cookieSession;
158 }
159
160
161
162
163 public final String getFilename() {
164 return filename;
165 }
166
167
168
169
170 public final void setFilename(final String filename) {
171 this.filename = filename;
172 }
173
174 @Override
175 public String toString() {
176 return "Command: " + currentCommand.name() + " Filename: " + filename +
177 " LogId: " + logid;
178 }
179 }