1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.preferences.web; |
18 | |
|
19 | |
import javax.servlet.http.HttpServletRequest; |
20 | |
|
21 | |
import org.kuali.rice.kew.exception.WorkflowServiceErrorImpl; |
22 | |
import org.kuali.rice.kew.preferences.Preferences; |
23 | |
import org.kuali.rice.kew.util.KEWConstants; |
24 | |
import org.kuali.rice.kns.exception.ValidationException; |
25 | |
import org.kuali.rice.kns.util.GlobalVariables; |
26 | |
import org.kuali.rice.kns.util.KNSConstants; |
27 | |
import org.kuali.rice.kns.web.struts.form.KualiForm; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
public class PreferencesForm extends KualiForm { |
38 | |
|
39 | |
private static final long serialVersionUID = 4536869031291955777L; |
40 | |
private static final String ERR_KEY_REFRESH_RATE_WHOLE_NUM = "preferences.refreshRate"; |
41 | |
private static final String ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM = "preferences.pageSize"; |
42 | |
private Preferences preferences; |
43 | 0 | private String methodToCall = ""; |
44 | |
private String returnMapping; |
45 | 0 | private boolean showOutbox = true; |
46 | |
|
47 | |
|
48 | |
private String backLocation; |
49 | |
|
50 | |
public String getReturnMapping() { |
51 | 0 | return returnMapping; |
52 | |
} |
53 | |
public void setReturnMapping(String returnMapping) { |
54 | 0 | this.returnMapping = returnMapping; |
55 | 0 | } |
56 | 0 | public PreferencesForm() { |
57 | 0 | preferences = new Preferences(); |
58 | 0 | } |
59 | |
public String getMethodToCall() { |
60 | 0 | return methodToCall; |
61 | |
} |
62 | |
public void setMethodToCall(String methodToCall) { |
63 | 0 | this.methodToCall = methodToCall; |
64 | 0 | } |
65 | |
public Preferences getPreferences() { |
66 | 0 | return preferences; |
67 | |
} |
68 | |
public void setPreferences(Preferences preferences) { |
69 | 0 | this.preferences = preferences; |
70 | 0 | } |
71 | |
public boolean isShowOutbox() { |
72 | 0 | return this.showOutbox; |
73 | |
} |
74 | |
public void setShowOutbox(boolean showOutbox) { |
75 | 0 | this.showOutbox = showOutbox; |
76 | 0 | } |
77 | |
|
78 | |
public String getBackLocation() { |
79 | 0 | return this.backLocation; |
80 | |
} |
81 | |
public void setBackLocation(String backLocation) { |
82 | 0 | this.backLocation = backLocation; |
83 | 0 | } |
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
@Override |
91 | |
public void populate(HttpServletRequest request) { |
92 | 0 | super.populate(request); |
93 | |
|
94 | 0 | if (getParameter(request, KNSConstants.RETURN_LOCATION_PARAMETER) != null) { |
95 | 0 | setBackLocation(getParameter(request, KNSConstants.RETURN_LOCATION_PARAMETER)); |
96 | |
} |
97 | 0 | } |
98 | |
|
99 | |
public void validatePreferences() { |
100 | |
|
101 | |
try { |
102 | 0 | new Integer(preferences.getRefreshRate().trim()); |
103 | 0 | } catch (NumberFormatException e) { |
104 | 0 | GlobalVariables.getMessageMap().putError(ERR_KEY_REFRESH_RATE_WHOLE_NUM, "general.message", "ActionList Refresh Rate must be in whole minutes"); |
105 | 0 | } catch (NullPointerException e1) { |
106 | 0 | GlobalVariables.getMessageMap().putError(ERR_KEY_REFRESH_RATE_WHOLE_NUM, "general.message", "ActionList Refresh Rate must be in whole minutes"); |
107 | 0 | } |
108 | |
|
109 | |
try { |
110 | 0 | new Integer(preferences.getPageSize().trim()); |
111 | 0 | if(new Integer(preferences.getPageSize().trim()) == 0){ |
112 | 0 | GlobalVariables.getMessageMap().putError(ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM, "general.message", "ActionList Page Size must be non-zero "); |
113 | |
} |
114 | 0 | } catch (NumberFormatException e) { |
115 | 0 | GlobalVariables.getMessageMap().putError(ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM, "general.message", "ActionList Page Size must be in whole minutes"); |
116 | 0 | } catch (NullPointerException e1) { |
117 | 0 | GlobalVariables.getMessageMap().putError(ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM, "general.message", "ActionList Page Size must be in whole minutes"); |
118 | 0 | } |
119 | |
|
120 | 0 | if (GlobalVariables.getMessageMap().hasErrors()) { |
121 | 0 | throw new ValidationException("errors in preferences"); |
122 | |
} |
123 | 0 | } |
124 | |
} |