1
2
3
4
5
6
7
8
9 package com.buckosoft.PicMan.web;
10
11 import java.io.IOException;
12
13 import javax.servlet.http.HttpServletRequest;
14 import javax.servlet.http.HttpServletResponse;
15
16 import org.apache.commons.logging.Log;
17 import org.apache.commons.logging.LogFactory;
18 import org.springframework.web.servlet.ModelAndView;
19
20 import com.buckosoft.BSAccount.web.BSAccountPageController;
21 import com.buckosoft.PicMan.business.PicManFacade;
22
23
24
25
26
27
28 public class MosaicAnalyseAjaxController extends BSAccountPageController {
29 private static boolean DEBUG = false;
30 protected final Log logger = LogFactory.getLog(getClass());
31
32 private PicManFacade pmf;
33
34
35
36
37 public void setPicMan(PicManFacade pmf) { this.pmf = pmf; }
38
39
40
41
42 public void setDEBUG(boolean debugFlag) {
43 DEBUG = debugFlag;
44 }
45
46
47
48
49
50
51 public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) {
52 String cid = request.getParameter("cid");
53 String c = request.getParameter("c");
54 String command = request.getParameter("command");
55 if (DEBUG) {
56 if (!command.equals("PicManStatus"))
57 logger.info("XML Request com=" + command + " c=" + c + " cid=" + cid);
58 }
59 response.setContentType("text/plain");
60 response.addHeader("Cache-Control", "max-age=0");
61 response.addHeader("Cache-Control", "no-cache");
62 response.addHeader("expires", "0");
63 response.addHeader("Expires", "Tue, 01 Jan 1980 1:00:00 GMT");
64 response.addHeader("Pragma", "no-cache");
65
66 try {
67 if (command == null) {
68 response.sendError(550, "No command in request");
69 return(null);
70 }
71 else if (command.equals("DeleteMosaicTiles")) {
72 pmf.getDB().deleteMosaicTiles(Integer.parseInt(c));
73 }
74 else {
75 response.sendError(551, "Unknown command '" + command + "' in request");
76 }
77 } catch (NumberFormatException e) {
78 logger.info(e);
79 pmf.addError(e);
80 } catch (IOException e) {
81 logger.info(e);
82 pmf.addError(e);
83 }
84
85 return null;
86 }
87
88 }