1 package org.melati.app.test;
2
3 import java.io.InputStream;
4
5 import org.melati.Melati;
6 import org.melati.MelatiConfig;
7 import org.melati.PoemContext;
8 import org.melati.app.InvalidArgumentsException;
9 import org.melati.app.PoemApp;
10 import org.melati.login.AccessHandler;
11 import org.melati.login.CommandLineAccessHandler;
12 import org.melati.login.OpenAccessHandler;
13 import org.melati.util.InstantiationPropertyException;
14 import org.melati.util.MelatiException;
15 import org.melati.util.MelatiRuntimeException;
16
17
18
19
20
21
22 public class ProtectedPoemApp extends PoemApp {
23
24 InputStream in = null;
25 public ProtectedPoemApp() {
26 super();
27 in = null;
28 }
29
30
31
32
33 protected MelatiConfig melatiConfig() throws MelatiException {
34 MelatiConfig config = super.melatiConfig();
35 try {
36 config.setAccessHandler((AccessHandler)CommandLineAccessHandler.class
37 .newInstance());
38 } catch (Exception e) {
39 throw new RuntimeException(e);
40 }
41 return config;
42
43 }
44
45
46
47
48
49 public Melati init(String[] args) throws MelatiException {
50 Melati melati = super.init(args);
51 if (in != null) {
52 CommandLineAccessHandler ah = (CommandLineAccessHandler)melati.getConfig().getAccessHandler();
53 ah.setInput(in);
54 ah.setOutput(System.err);
55 }
56 return melati;
57
58 }
59
60
61
62
63
64 protected void doPoemRequest(Melati melati) throws Exception {
65
66 melati.getDatabase().getUserTable().getTableInfo().
67 setDefaultcanread(melati.getDatabase().getCanAdminister());
68 super.doPoemRequest(melati);
69 }
70
71
72
73
74
75
76 public static void main(String[] args) throws Exception {
77 ProtectedPoemApp me = new ProtectedPoemApp();
78 me.run(args);
79 }
80 protected PoemContext poemContext(Melati melati)
81 throws InvalidArgumentsException {
82 return poemContextWithLDB(melati,"appjunit");
83 }
84
85
86
87
88 public void setInput(InputStream is) {
89 in = is;
90 }
91 }