1
5 package com.borneo.util;
6
7 import java.io.File;
8
9 import javax.servlet.http.HttpServletRequest;
10import javax.servlet.http.HttpSession;
11
12import org.apache.log4j.Logger;
13import org.apache.log4j.PropertyConfigurator;
14
15
26
27public class DefaultFileRenamePolicySesn
28 implements FileRenamePolicySesn
29{
30 public DefaultFileRenamePolicySesn()
33 {
34 }
35
36 public File rename(File f, HttpServletRequest request, boolean flag)
37 {
38 if((new File((File)request.getSession().getServletContext().getAttribute("javax.servlet.context.tempdir"), request.getSession().getId().substring(0, 15) + f.getName())).exists() == flag)
39 {
40 log.debug("boolean vrsn : hit substring");
41 return new File((File)request.getSession().getServletContext().getAttribute("javax.servlet.context.tempdir"), request.getSession().getId().substring(0, 15) + f.getName());
42 } else
43 {
44 log.debug("boolean vrsn : NOhit substring");
45 return new File((File)request.getSession().getServletContext().getAttribute("javax.servlet.context.tempdir"), f.getName());
46 }
47 }
48
49 public File rename(File f, HttpServletRequest request)
50 {
51 log.debug("plain vrsn ");
52 return new File((File)request.getSession().getServletContext().getAttribute("javax.servlet.context.tempdir"), request.getSession().getId().substring(0, 15) + f.getName());
53 }
54
55 public File rename(File f, HttpSession session)
56 {
57 log.debug("plain vrsn ");
58 return new File((File)session.getServletContext().getAttribute("javax.servlet.context.tempdir"), session.getId().substring(0, 15) + f.getName());
59 }
60
61 protected static Logger log;
62
63 static
64 {
65 log = Logger.getLogger(DefaultFileRenamePolicySesn.class.getName());
66 PropertyConfigurator.configure(com.borneo.util.DefaultFileRenamePolicySesn.class.getClassLoader().getResource("config/log4j.properties"));
67
68 }
69}
70