1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.fckeditor.handlers;
22
23 import javax.servlet.http.HttpServletRequest;
24
25 import net.fckeditor.requestcycle.UserAction;
26 import net.fckeditor.requestcycle.UserPathBuilder;
27
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30
31
32
33
34
35
36
37 public class RequestCycleHandler {
38 private static Logger logger = LoggerFactory.getLogger(RequestCycleHandler.class);
39 private static UserAction userAction = null;
40 private static UserPathBuilder userPathBuilder = null;
41
42 static {
43
44
45
46 String fqcn = PropertiesLoader.getProperty("connector.userActionImpl");
47 if (fqcn == null)
48 logger.warn("No property found for UserAction implementation, any user action will be disabled!");
49 else {
50 try {
51 Class<?> clazz = Class.forName(fqcn);
52 userAction = (UserAction) clazz.newInstance();
53 logger.info("UserAction implementation successfully instantiated!");
54 } catch (Exception e) {
55 logger.error("Couldn't instantiate class [".concat(fqcn).concat(
56 "], any user action will disabled!"), e);
57 }
58 }
59
60
61 fqcn = PropertiesLoader.getProperty("connector.userPathBuilderImpl");
62 if (fqcn == null)
63 logger.warn("No property found for UserPathBuilder implementation! "
64 .concat("The 'DefaultUserFilesPath' will be used in the ConnectorServlet!"));
65 else {
66 try {
67 Class<?> clazz = Class.forName(fqcn);
68 userPathBuilder = (UserPathBuilder) clazz.newInstance();
69 logger.info("UserPathBuilder object successfully instantiated!");
70 } catch (Exception e) {
71 logger.error("Couldn't instantiate class [".concat(fqcn)
72 .concat("], The 'DefaultUserFilesPath' will be used in the ConnectorServlet!"), e);
73 }
74 }
75 }
76
77
78
79
80
81
82
83
84
85 public static boolean isEnabledForFileBrowsing(final HttpServletRequest request) {
86 return (userAction != null && userAction.isEnabledForFileBrowsing(request));
87 }
88
89
90
91
92
93
94
95
96
97 public static boolean isEnabledForFileUpload(final HttpServletRequest request) {
98 return (userAction != null && userAction.isEnabledForFileUpload(request));
99 }
100
101
102
103
104
105
106
107
108
109
110 protected static String getUserFilePath(final HttpServletRequest request) {
111 return (userPathBuilder != null) ? userPathBuilder.getUserFilesPath(request) : null;
112 }
113 }