| 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 | 0 | public class MosaicAnalyseAjaxController extends BSAccountPageController { |
| 29 | 0 | private static boolean DEBUG = false; |
| 30 | 0 | protected final Log logger = LogFactory.getLog(getClass()); |
| 31 | |
|
| 32 | |
private PicManFacade pmf; |
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | 0 | public void setPicMan(PicManFacade pmf) { this.pmf = pmf; } |
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
public void setDEBUG(boolean debugFlag) { |
| 43 | 0 | DEBUG = debugFlag; |
| 44 | 0 | } |
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) { |
| 52 | 0 | String cid = request.getParameter("cid"); |
| 53 | 0 | String c = request.getParameter("c"); |
| 54 | 0 | String command = request.getParameter("command"); |
| 55 | 0 | if (DEBUG) { |
| 56 | 0 | if (!command.equals("PicManStatus")) |
| 57 | 0 | logger.info("XML Request com=" + command + " c=" + c + " cid=" + cid); |
| 58 | |
} |
| 59 | 0 | response.setContentType("text/plain"); |
| 60 | 0 | response.addHeader("Cache-Control", "max-age=0"); |
| 61 | 0 | response.addHeader("Cache-Control", "no-cache"); |
| 62 | 0 | response.addHeader("expires", "0"); |
| 63 | 0 | response.addHeader("Expires", "Tue, 01 Jan 1980 1:00:00 GMT"); |
| 64 | 0 | response.addHeader("Pragma", "no-cache"); |
| 65 | |
|
| 66 | |
try { |
| 67 | 0 | if (command == null) { |
| 68 | 0 | response.sendError(550, "No command in request"); |
| 69 | 0 | return(null); |
| 70 | |
} |
| 71 | 0 | else if (command.equals("DeleteMosaicTiles")) { |
| 72 | 0 | pmf.getDB().deleteMosaicTiles(Integer.parseInt(c)); |
| 73 | |
} |
| 74 | |
else { |
| 75 | 0 | response.sendError(551, "Unknown command '" + command + "' in request"); |
| 76 | |
} |
| 77 | 0 | } catch (NumberFormatException e) { |
| 78 | 0 | logger.info(e); |
| 79 | 0 | pmf.addError(e); |
| 80 | 0 | } catch (IOException e) { |
| 81 | 0 | logger.info(e); |
| 82 | 0 | pmf.addError(e); |
| 83 | 0 | } |
| 84 | |
|
| 85 | 0 | return null; |
| 86 | |
} |
| 87 | |
|
| 88 | |
} |