1 package com.instantbank.lettertemplate.editor.applet;
2
3 import java.io.ObjectInputStream;
4 import java.io.Serializable;
5
6 import java.net.URL;
7 import java.net.MalformedURLException;
8
9 import java.util.ArrayList;
10
11 import java.applet.AppletContext;
12
13 import com.instantbank.common.uiutils.MessageFrame;
14
15 import com.instantbank.lettertemplate.editor.util.LetterOp;
16 import com.instantbank.component.lettertemplate.util.LetterComponent;
17 import com.instantbank.component.lettertemplate.util.Template;
18 import com.instantbank.common.utilcomponents.CodeDescription;
19
20
27 public class TemplateEditorProxy {
28
31 URL servlet;
32
33
37 URL webBase;
38
39
42 URL timeout;
43
44
47 ObjectInputStream in;
48
49
50
57 public TemplateEditorProxy(URL web) throws MalformedURLException {
58 webBase = web;
59 servlet = new URL
60 (webBase,
61 "/lettertemplate/editor/templatecontroller");
62 timeout = new URL
63 (webBase,
64 "/lettertemplate/control_web/TimeOutPage.jsp");
65
66 }
67
68
69
76 public boolean controlTimeout(AppletContext appContext) {
77 Integer opCode = new Integer(LetterOp.CONTROLTIMEOUT);
78 Serializable objs[] = {opCode};
79 boolean existsTimeout = false;
80 try {
81 in = TemplateEditorSender.postObjects(servlet, objs);
82 existsTimeout = ((Boolean)in.readObject()).booleanValue();
83 in.close();
84 if(existsTimeout) {
85 appContext.showDocument(timeout);
86 }
87 }
88 catch(Throwable ex) {
89 appContext.showDocument(timeout);
90 }
91 return existsTimeout;
92 }
93
94
95
101
102 public String[] loadImagesNamesRepository() throws Exception {
103 Integer opCode = new Integer(LetterOp.LOADIMGNAMES);
104 Serializable objs[] = {opCode};
105 in = TemplateEditorSender.postObjects(servlet, objs);
106 String[] resultado = (String[])in.readObject();
107 in.close();
108 return resultado;
109 }
110
111
112
121 public CodeDescription[] storeTemplate(Template template) throws Exception {
122 Integer opCode = new Integer(LetterOp.STORETEMPLATE);
123 Serializable objs[] = {opCode, template};
124 in = TemplateEditorSender.postObjects(servlet, objs);
125 CodeDescription[] resultado = (CodeDescription[])in.readObject();
126 in.close();
127 return resultado;
128 }
129
130
131
141 public byte[] loadImageRepository(String name) throws Exception {
142 Integer opCode = new Integer(LetterOp.LOADIMG);
143 Serializable objs[] = {opCode, name};
144 in = TemplateEditorSender.postObjects(servlet, objs);
145 byte[] res = (byte[])in.readObject();
146 in.close();
147 return res;
148 }
149
150
151
157 public void exit(String url) throws Exception {
158 Integer opCode = new Integer(LetterOp.EXIT);
159 Serializable objs[] = {opCode, url};
160 TemplateEditorSender.postObjectsNoAnswer(servlet, objs);
161 }
162
163
164
171 public CodeDescription[] loadCategories() throws Exception {
172 Serializable objs[] = {new Integer(LetterOp.LOADCATEGORIES)};
173 in = TemplateEditorSender.postObjects(servlet, objs);
174 CodeDescription[] res = (CodeDescription[])in.readObject();
175 in.close();
176
177 return res;
178 }
179
180
181
191 public CodeDescription[] loadTemplatesDescription(long category, int pType)
192 throws Exception {
193 Serializable objs[] = {new Integer(LetterOp.LOADTEMPLNAMES),
194 new Long(category),
195 new Integer(pType)};
196
197 in = TemplateEditorSender.postObjects(servlet, objs);
198 CodeDescription[] res = (CodeDescription[])in.readObject();
199 in.close();
200 return res;
201 }
202
203
204
213 public CodeDescription[] loadTemplateCodes(long code) throws Exception {
214 Serializable objs[] = {new Integer(LetterOp.LOADTEMPLCODES),
215 new Long(code)
216 };
217
218 in = TemplateEditorSender.postObjects(servlet, objs);
219 CodeDescription[] res = (CodeDescription[])in.readObject();
220 in.close();
221 return res;
222 }
223
224
225
235 public CodeDescription[] loadComponentsDescription(int cmpType, int pType)
236 throws Exception {
237 Serializable objs[] = {new Integer(LetterOp.LOADCOMPDESCR),
238 new Integer(cmpType),
239 new Integer(pType)};
240
241 in = TemplateEditorSender.postObjects(servlet, objs);
242 CodeDescription[] res = (CodeDescription[])in.readObject();
243 in.close();
244 return res;
245 }
246
247
248
258 public ArrayList loadTemplate(long code) throws Exception {
259 Serializable objs[] = {new Integer(LetterOp.LOADTEMPL), new Long(code)};
260 in = TemplateEditorSender.postObjects(servlet, objs);
261 ArrayList res = (ArrayList)in.readObject();
262 in.close();
263 return res;
264 }
265
266
267
284 public CodeDescription[] loadCodesStamps(long category, int printType,
285 String template, String header, String body, String closing)
286 throws Exception {
287 Serializable objs[] = {new Integer(LetterOp.LOADCODESTAMP),
288 new Long(category),
289 new Integer(printType),
290 template, header, body, closing
291 };
292 in = TemplateEditorSender.postObjects(servlet, objs);
293 CodeDescription[] res = (CodeDescription[])in.readObject();
294 in.close();
295 return res;
296 }
297
298
299
310 public CodeDescription loadComponentCode(int compType, int printType, String name)
311 throws Exception {
312 Serializable objs[] = {new Integer(LetterOp.LOADCOMPCODE),
313 new Integer(compType),
314 new Integer(printType),
315 name};
316 in = TemplateEditorSender.postObjects(servlet, objs);
317 CodeDescription res = (CodeDescription)in.readObject();
318 in.close();
319 return res;
320 }
321
322
323
334 public ArrayList loadComponent(long code) throws Exception {
335 Serializable objs[] = {new Integer(LetterOp.LOADCOMPONENT),
336 new Long(code)
337 };
338 in = TemplateEditorSender.postObjects(servlet, objs);
339 ArrayList res = (ArrayList)in.readObject();
340 in.close();
341 return res;
342 }
343
344
345
354 public CodeDescription storeComponent(LetterComponent component)
355 throws Exception {
356 Serializable objs[] = {new Integer(LetterOp.STORECOMPONENT),
357 component
358 };
359 in = TemplateEditorSender.postObjects(servlet, objs);
360 CodeDescription res = (CodeDescription)in.readObject();
361 in.close();
362 return res;
363 }
364
365
366
376 public CodeDescription storeComponentAs(
377 long templateCode, LetterComponent component) throws Exception {
378 Serializable objs[] = {new Integer(LetterOp.STORECOMPONENTAS),
379 new Long(templateCode),
380 component
381 };
382 in = TemplateEditorSender.postObjects(servlet, objs);
383 CodeDescription res = (CodeDescription)in.readObject();
384 in.close();
385 return res;
386 }
387
388
389
397 public ArrayList loadVariables() throws Exception {
398 Serializable objs[] = {new Integer(LetterOp.LOADVARIABLES)};
399 in = TemplateEditorSender.postObjects(servlet, objs);
400 ArrayList res = (ArrayList)in.readObject();
401 in.close();
402 return res;
403 }
404
405
406
413 public CodeDescription[] loadVariableFormats() throws Exception {
414 Serializable objs[] = {new Integer(LetterOp.LOADVARIABLEFORMATS)};
415 in = TemplateEditorSender.postObjects(servlet, objs);
416 CodeDescription[] res = (CodeDescription[])in.readObject();
417 in.close();
418 return res;
419 }
420
421
422
428 public String extraservice() throws Exception {
429 Serializable objs[] = {new Integer(6210)};
430 in = TemplateEditorSender.postObjects(servlet, objs);
431 String res = (String)in.readObject();
432 in.close();
433 return res;
434 }
435
436 }
437