forked from playframework/play1
/
Application.java
294 lines (236 loc) · 7.23 KB
/
Application.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
package controllers;
import java.util.*;
import java.io.File;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.apache.commons.mail.EmailAttachment;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import play.*;
import play.mvc.*;
import play.i18n.Lang;
import play.libs.*;
import play.jobs.*;
import models.*;
import utils.*;
import jobs.*;
import javax.mail.internet.InternetAddress;
@play.db.jpa.Transactional
public class Application extends Controller {
// bug
public static void aa() {
try {
@SuppressWarnings("unused")
int test = 1;
} catch (Exception ex) {
}
}
public static void helloZen() {
renderText("Hello");
}
public static void myHomePage(String clientName) {
renderText(clientName);
}
public static void some1() {
renderText(Invoker.InvocationContext.current());
}
@Youhou
public static void some2() {
renderText(Invoker.InvocationContext.current());
}
@Youhou
public static void some3() throws Exception {
JobWithContext job = new JobWithContext();
Future<String> future = job.now();
renderText(future.get());
}
// bug
public static void aaa() {
try {
boolean test = TestUtil.invokeTest("a");
Logger.info("test:" + test);
} catch (Exception ex) {
ex.printStackTrace();
}
renderText("IT WORKS");
}
public static void ok(String re) {
renderText("OK: " + re);
}
public static void index() {
routeArgs.put("lucky", "strike");
render();
}
public static void showIt() {
renderText("Done");
}
public static void index2() {
renderText(Router.reverse("Application.index2"));
}
public static void simpleStatusCode() {
response.status = 204;
}
public static void imagesAssets() {
}
public static void dashboard(String client) {
renderText(client);
}
public static void hello(String name) {
render(name);
}
public static void helloWorld(String name) {
render("/Application/hello.html", name);
}
public static void helloSteph(String name) {
render("/Application/hello.html", name);
}
public static void yop() {
render();
}
public static void alertConfirmPrompt() {
render();
}
public static void dynamicClassBinding(boolean fail) {
render(fail);
}
public static void tagContexts() {
render();
}
public static void book(Date at) {
java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("dd/MM/yy");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
renderText("Booked at %s !!", df.format(at));
}
public static void escapeData() {
String oops = " <i>Yop</i> ";
render(oops);
}
public static void aGetForm(String name) {
render("Application/hello.html", name);
}
public static void aGetForm2(String name) {
name = "2" + name;
render("Application/hello.html", name);
}
public static void optional() {
renderText("OK");
}
public static void reverserouting() {
render("Application/reverse.html");
}
public static void reverserouting2() {
render("Application/reverse2.html");
}
public static void reverserouting3() {
Object def = reverse(); {
JPABinding.save(new Project("COLCOZ"));
}
renderText(def);
}
public static void jsRoute() {
render();
}
public static void jsRouteError() {
render();
}
public static void mail() {
notifiers.Welcome.welcome();
renderText("OK");
}
public static void mail2() {
Welcome.welcome();
renderText("OK2");
}
public static void mail3() {
notifiers.Welcome.welcome2();
renderText("OK3");
}
public static void mail4() {
notifiers.Welcome.welcome3();
renderText("OK4");
}
public static void mail5() throws EmailException {
HtmlEmail email = new HtmlEmail();
email.setHtmlMsg("<html><body><h1>A Title</h1></body></html>");
email.setTextMsg("alternative message");
EmailAttachment attachment = new EmailAttachment();
attachment.setDescription("An image");
attachment.setDisposition(EmailAttachment.ATTACHMENT);
attachment.setPath(Play.applicationPath.getPath() + java.io.File.separator + "test" + java.io.File.separator + "fond2.png");
EmailAttachment attachment2 = new EmailAttachment();
attachment2.setName("fond3.jpg");
attachment2.setPath(Play.applicationPath.getPath() + java.io.File.separator + "test" + java.io.File.separator + "fond3.jpg");
email.attach(attachment);
email.attach(attachment2);
email.setFrom("test@localhost");
email.addTo("test@localhost");
email.setSubject("test attachments");
Mail.send(email);
renderText("OK5");
}
public static void mailWithUrls() {
notifiers.Welcome.welcome_mailWithUrls(false);
renderText("OK_mailWithUrls");
}
public static class MailJob extends Job {
@Override
public void doJob() {
notifiers.Welcome.welcome_mailWithUrls(true);
}
}
public static void mailWithUrlsInJob() throws Exception {
new MailJob().now().get();
renderText("OK_mailWithUrlsInJob");
}
public static void ifthenelse() {
boolean a = true;
boolean b = false;
String c = "";
String d = "Yop";
int e = 0;
int f = 5;
Boolean g = null;
Boolean h = true;
Object i = null;
Object j = new Object();
render(a, b, c, d, e, f, g, h, i, j);
}
public static void listTag() {
List<String> a = new ArrayList<String>();
a.add("aa");
a.add("ab");
a.add("ac");
int[] b = new int[]{0, 1, 2, 3};
Iterator d = a.iterator();
render(a, b, d);
}
public static void a() {
render();
}
public static void useSpringBean() {
}
@javax.inject.Inject
static Test myTest;
public static void useSpringBeanInject() {
renderText(myTest.yop());
}
public static void googleSearch(String word) throws InterruptedException, ExecutionException {
WS.HttpResponse response = WS.url("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=%s", word).get();
long results = response.getJson().getAsJsonObject().getAsJsonObject("responseData").getAsJsonObject("cursor").getAsJsonPrimitive("estimatedResultCount").getAsLong();
renderText(results);
}
public static void selectTag(){
List<User> users = new ArrayList<User>(10);
User user;
for(long i = 0; i < 10; i++) {
user = new User("User-" + i);
user.k = i;
user.i = (int) i;
users.add(user);
}
render(users);
}
public static void fastTag_render_test() {
render();
}
}