01: package org.claros.intouch.common.utility;
02:
03: import java.io.File;
04:
05: import javax.servlet.ServletException;
06: import javax.servlet.http.HttpServlet;
07:
08: import org.apache.commons.logging.Log;
09: import org.apache.commons.logging.LogFactory;
10: import org.claros.commons.exception.SystemException;
11:
12: public class Initiator extends HttpServlet {
13: private static final long serialVersionUID = -1124952420163920030L;
14: private static Log log = LogFactory.getLog(Initiator.class);
15:
16: /**
17: * Initialization of the servlet. <br>
18: *
19: * @throws ServletException if an error occurs
20: */
21: public void init() throws ServletException {
22: File dir = new File(Constants.tmpDir);
23:
24: // if temp directory doesn't exist, try to create a new one.
25: if (!dir.exists()) {
26: dir.mkdir();
27: }
28:
29: // delete all files in the tempDir
30: if (dir.exists() && dir.isDirectory()) {
31: String files[] = dir.list();
32: for (int i = 0; i < files.length; i++) {
33: File f = new File(Constants.tmpDir + "/" + files[i]);
34: f.delete();
35: }
36: } else {
37: log
38: .fatal("Temp dir does not exist or is not a directory, please check the tmp-dir setting in the config.xml file");
39: throw new SystemException();
40: }
41: }
42:
43: }
|