fixed category handling.
@@ -2,6 +2,7 @@ | ||
2 | 2 | |
3 | 3 | import java.io.Serializable; |
4 | 4 | import java.sql.Timestamp; |
5 | +import java.util.ArrayList; | |
5 | 6 | import java.util.Date; |
6 | 7 | import java.util.List; |
7 | 8 |
@@ -9,6 +10,7 @@ | ||
9 | 10 | import jp.sf.pal.notepad.common.dxo.PagerDxo; |
10 | 11 | import jp.sf.pal.notepad.common.util.PagingResultBeanWrapper; |
11 | 12 | import jp.sf.pal.notepad.db.allcommon.cbean.PagingResultBean; |
13 | +import jp.sf.pal.notepad.db.allcommon.cbean.UnionQuery; | |
12 | 14 | import jp.sf.pal.notepad.db.cbean.NotepadCB; |
13 | 15 | import jp.sf.pal.notepad.db.cbean.UserInfoCB; |
14 | 16 | import jp.sf.pal.notepad.db.exbhv.NotepadBhv; |
@@ -53,8 +55,17 @@ | ||
53 | 55 | } |
54 | 56 | } |
55 | 57 | |
56 | - public List<Notepad> getNotepadList(NotepadPager notepadPager) { | |
58 | + public List<Notepad> getNotepadList(final NotepadPager notepadPager) { | |
59 | + return getNotepadList(notepadPager, false); | |
60 | + } | |
57 | 61 | |
62 | + public List<Notepad> getNotepadList(final NotepadPager notepadPager, | |
63 | + boolean permission) { | |
64 | + if (!permission && notepadPager.getCreatedBy() == null) { | |
65 | + // no permission | |
66 | + return new ArrayList<Notepad>(); | |
67 | + } | |
68 | + | |
58 | 69 | HotdeployUtil.rebuildValue(notepadPager); |
59 | 70 | |
60 | 71 | NotepadCB cb = new NotepadCB(); |
@@ -69,24 +80,46 @@ | ||
69 | 80 | |
70 | 81 | if (notepadPager.getCreatedBy() != null) { |
71 | 82 | if (notepadPager.getCategoryId() != null) { |
83 | + cb.query().setCategoryId_Equal(notepadPager.getCategoryId()); | |
84 | + | |
72 | 85 | NotepadCategory notepadCategory = categoryService |
73 | 86 | .getCategory(notepadPager.getCategoryId()); |
74 | - if (NotepadConstants.DEFAULT_CATEGORY.equals(notepadCategory | |
87 | + if (NotepadConstants.PRIVATE_CATEGORY.equals(notepadCategory | |
75 | 88 | .getType())) { |
76 | 89 | cb.query().setCreatedBy_Equal(notepadPager.getCreatedBy()); |
77 | - } else if (NotepadConstants.PRIVATE_CATEGORY | |
90 | + cb.query().queryNotepadCategory().setCreatedBy_Equal( | |
91 | + notepadPager.getCreatedBy()); | |
92 | + } else if (NotepadConstants.PUBLIC_CATEGORY | |
78 | 93 | .equals(notepadCategory.getType())) { |
79 | - cb.query().setCreatedBy_Equal(notepadPager.getCreatedBy()); | |
94 | + cb.query().queryNotepadCategory().setType_Equal( | |
95 | + NotepadConstants.PUBLIC_CATEGORY); | |
96 | + } else if (NotepadConstants.SHARED_CATEGORY | |
97 | + .equals(notepadCategory.getType())) { | |
98 | + cb.query().queryNotepadCategory().setType_Equal( | |
99 | + NotepadConstants.SHARED_CATEGORY); | |
80 | 100 | } |
81 | 101 | } else { |
102 | + // All | |
82 | 103 | cb.query().setCreatedBy_Equal(notepadPager.getCreatedBy()); |
104 | + cb.unionAll(new UnionQuery<NotepadCB>() { | |
105 | + public void query(NotepadCB unionCB) { | |
106 | + unionCB.query().setDeletedBy_IsNull(); | |
107 | + List<String> typeList = new ArrayList<String>(); | |
108 | + typeList.add(NotepadConstants.PUBLIC_CATEGORY); | |
109 | + typeList.add(NotepadConstants.SHARED_CATEGORY); | |
110 | + unionCB.query().queryNotepadCategory().setType_InScope( | |
111 | + typeList); | |
112 | + unionCB.query().setCreatedBy_NotEqual( | |
113 | + notepadPager.getCreatedBy()); | |
114 | + } | |
115 | + }); | |
83 | 116 | } |
84 | - } | |
85 | - if (notepadPager.getCategoryId() != null) { | |
117 | + } else if (notepadPager.getCategoryId() != null) { | |
86 | 118 | cb.query().setCategoryId_Equal(notepadPager.getCategoryId()); |
87 | 119 | } |
88 | 120 | cb.query().setDeletedBy_IsNull(); |
89 | 121 | |
122 | + cb.query().addOrderBy_CategoryId_Asc(); | |
90 | 123 | cb.query().addOrderBy_SortOrder_Asc(); |
91 | 124 | |
92 | 125 | PagingResultBean<Notepad> messageList = notepadBhv.selectPage(cb); |
@@ -111,6 +144,7 @@ | ||
111 | 144 | |
112 | 145 | cb.query().setId_Equal(id); |
113 | 146 | return notepadBhv.selectEntity(cb); |
147 | + // need to check a permission of this entity. | |
114 | 148 | } |
115 | 149 | |
116 | 150 | public void store(Notepad notepad) { |
@@ -177,10 +211,6 @@ | ||
177 | 211 | cb.query().setSortOrder_GreaterEqual(notepad.getSortOrder()); |
178 | 212 | cb.query().addOrderBy_SortOrder_Asc(); |
179 | 213 | cb.query().setCategoryId_Equal(notepad.getCategoryId()); |
180 | - if (NotepadConstants.DEFAULT_CATEGORY.equals(notepad | |
181 | - .getNotepadCategory().getType())) { | |
182 | - cb.query().setCreatedBy_Equal(notepad.getCreatedBy()); | |
183 | - } | |
184 | 214 | List<Notepad> notepadList = notepadBhv.selectPage(cb); |
185 | 215 | if (notepadList != null && !notepadList.isEmpty()) { |
186 | 216 | Notepad targetNotepad = notepadList.get(0); |
@@ -210,10 +240,6 @@ | ||
210 | 240 | cb.query().setSortOrder_LessEqual(notepad.getSortOrder()); |
211 | 241 | cb.query().addOrderBy_SortOrder_Desc(); |
212 | 242 | cb.query().setCategoryId_Equal(notepad.getCategoryId()); |
213 | - if (NotepadConstants.DEFAULT_CATEGORY.equals(notepad | |
214 | - .getNotepadCategory().getType())) { | |
215 | - cb.query().setCreatedBy_Equal(notepad.getCreatedBy()); | |
216 | - } | |
217 | 243 | List<Notepad> notepadList = notepadBhv.selectPage(cb); |
218 | 244 | if (notepadList != null && !notepadList.isEmpty()) { |
219 | 245 | Notepad targetNotepad = notepadList.get(0); |
@@ -2,6 +2,7 @@ | ||
2 | 2 | |
3 | 3 | import java.io.Serializable; |
4 | 4 | import java.sql.Timestamp; |
5 | +import java.util.ArrayList; | |
5 | 6 | import java.util.Date; |
6 | 7 | import java.util.List; |
7 | 8 |
@@ -49,7 +50,16 @@ | ||
49 | 50 | } |
50 | 51 | |
51 | 52 | public List<NotepadCategory> getCategoryList(CategoryPager categoryPager) { |
53 | + return getCategoryList(categoryPager, false); | |
54 | + } | |
52 | 55 | |
56 | + public List<NotepadCategory> getCategoryList(CategoryPager categoryPager, | |
57 | + boolean permission) { | |
58 | + if (!permission && categoryPager.getCreatedBy() == null) { | |
59 | + // no permission | |
60 | + return new ArrayList<NotepadCategory>(); | |
61 | + } | |
62 | + | |
53 | 63 | HotdeployUtil.rebuildValue(categoryPager); |
54 | 64 | |
55 | 65 | NotepadCategoryCB cb = new NotepadCategoryCB(); |
@@ -86,6 +96,7 @@ | ||
86 | 96 | |
87 | 97 | cb.query().setId_Equal(id); |
88 | 98 | return notepadCategoryBhv.selectEntity(cb); |
99 | + // need to check a permission of this entity. | |
89 | 100 | } |
90 | 101 | |
91 | 102 | public void store(NotepadCategory category) { |
@@ -227,8 +238,10 @@ | ||
227 | 238 | cb.unionAll(new UnionQuery<NotepadCategoryCB>() { |
228 | 239 | public void query(NotepadCategoryCB unionCB) { |
229 | 240 | unionCB.query().setDeletedBy_IsNull(); |
230 | - unionCB.query() | |
231 | - .setType_Equal(NotepadConstants.PRIVATE_CATEGORY); | |
241 | + List<String> typeList = new ArrayList<String>(); | |
242 | + typeList.add(NotepadConstants.PRIVATE_CATEGORY); | |
243 | + typeList.add(NotepadConstants.PUBLIC_CATEGORY); | |
244 | + unionCB.query().setType_InScope(typeList); | |
232 | 245 | unionCB.query().setCreatedBy_Equal(createdBy); |
233 | 246 | } |
234 | 247 | }); |
@@ -18,10 +18,6 @@ | ||
18 | 18 | |
19 | 19 | public static final String FALSE = "F"; |
20 | 20 | |
21 | - public static final Integer DEFAULT_CATEGORY_ID = Integer.valueOf(1); | |
22 | - | |
23 | - public static final String DEFAULT_CATEGORY = "D"; | |
24 | - | |
25 | 21 | public static final String PUBLIC_CATEGORY = "P"; |
26 | 22 | |
27 | 23 | public static final String PRIVATE_CATEGORY = "R"; |
@@ -52,7 +52,7 @@ | ||
52 | 52 | // page navi |
53 | 53 | notepadPager.setCreatedBy(null); |
54 | 54 | notepadPager.setCategoryId(null); |
55 | - notepadItems = notepadService.getNotepadList(notepadPager); | |
55 | + notepadItems = notepadService.getNotepadList(notepadPager, true); | |
56 | 56 | |
57 | 57 | return "index.jsp"; |
58 | 58 | } |
@@ -211,12 +211,7 @@ | ||
211 | 211 | private void loadLink() { |
212 | 212 | Long linkId = Long.parseLong(notepadForm.id); |
213 | 213 | |
214 | - Notepad link = notepadService.getNotepad(linkId); | |
215 | - if (link == null) { | |
216 | - // throw an exception | |
217 | - throw new ActionMessagesException("errors.could_not_find_notepad", | |
218 | - new Object[] { linkId }); | |
219 | - } | |
214 | + Notepad link = getNotepad(linkId); | |
220 | 215 | notepadDxo.convertFromNotepadToForm(link, notepadForm); |
221 | 216 | |
222 | 217 | } |
@@ -225,7 +220,7 @@ | ||
225 | 220 | Notepad link; |
226 | 221 | if (notepadForm.mode == NotepadConstants.EDIT_MODE) { |
227 | 222 | Long linkId = Long.parseLong(notepadForm.id); |
228 | - link = notepadService.getNotepad(linkId); | |
223 | + link = getNotepad(linkId); | |
229 | 224 | link.setUpdatedBy(request.getRemoteUser()); |
230 | 225 | } else { |
231 | 226 | link = new Notepad(); |
@@ -238,6 +233,16 @@ | ||
238 | 233 | return link; |
239 | 234 | } |
240 | 235 | |
236 | + private Notepad getNotepad(Long id) { | |
237 | + Notepad notepad = notepadService.getNotepad(id); | |
238 | + if (notepad == null) { | |
239 | + // throw an exception | |
240 | + throw new ActionMessagesException("errors.could_not_find_notepad", | |
241 | + new Object[] { id }); | |
242 | + } | |
243 | + return notepad; | |
244 | + } | |
245 | + | |
241 | 246 | private void loadListPageParameters() { |
242 | 247 | } |
243 | 248 |
@@ -48,7 +48,7 @@ | ||
48 | 48 | protected String displayList() { |
49 | 49 | // page navi |
50 | 50 | categoryPager.setCreatedBy(null); |
51 | - categoryItems = categoryService.getCategoryList(categoryPager); | |
51 | + categoryItems = categoryService.getCategoryList(categoryPager, true); | |
52 | 52 | return "index.jsp"; |
53 | 53 | } |
54 | 54 |
@@ -140,12 +140,8 @@ | ||
140 | 140 | if (categoryForm.id == null) { |
141 | 141 | throw new ActionMessagesException("errors.invalid.id"); |
142 | 142 | } |
143 | - NotepadCategory category = categoryService.getCategory(Integer | |
143 | + NotepadCategory category = getNotepadCategory(Integer | |
144 | 144 | .parseInt(categoryForm.id)); |
145 | - if (category == null) { | |
146 | - throw new ActionMessagesException("errors.could_not_find_category", | |
147 | - new Object[] { categoryForm.id }); | |
148 | - } | |
149 | 145 | try { |
150 | 146 | categoryService.moveDown(category); |
151 | 147 | NotepadUtil.addMessage(request, "success.move_category_up"); |
@@ -164,12 +160,8 @@ | ||
164 | 160 | if (categoryForm.id == null) { |
165 | 161 | throw new ActionMessagesException("errors.invalid.id"); |
166 | 162 | } |
167 | - NotepadCategory category = categoryService.getCategory(Integer | |
163 | + NotepadCategory category = getNotepadCategory(Integer | |
168 | 164 | .parseInt(categoryForm.id)); |
169 | - if (category == null) { | |
170 | - throw new ActionMessagesException("errors.could_not_find_category", | |
171 | - new Object[] { categoryForm.id }); | |
172 | - } | |
173 | 165 | try { |
174 | 166 | categoryService.moveUp(category); |
175 | 167 | NotepadUtil.addMessage(request, "success.move_category_down"); |
@@ -240,12 +232,7 @@ | ||
240 | 232 | private void loadCategory() { |
241 | 233 | Integer categoryId = Integer.parseInt(categoryForm.id); |
242 | 234 | |
243 | - NotepadCategory category = categoryService.getCategory(categoryId); | |
244 | - if (category == null) { | |
245 | - // throw an exception | |
246 | - throw new ActionMessagesException("errors.could_not_find_category", | |
247 | - new Object[] { categoryId }); | |
248 | - } | |
235 | + NotepadCategory category = getNotepadCategory(categoryId); | |
249 | 236 | categoryDxo.convertFromCategoryToForm(category, categoryForm); |
250 | 237 | |
251 | 238 | } |
@@ -254,7 +241,7 @@ | ||
254 | 241 | NotepadCategory category; |
255 | 242 | if (categoryForm.mode == NotepadConstants.EDIT_MODE) { |
256 | 243 | Integer categoryId = Integer.parseInt(categoryForm.id); |
257 | - category = categoryService.getCategory(categoryId); | |
244 | + category = getNotepadCategory(categoryId); | |
258 | 245 | category.setUpdatedBy(request.getRemoteUser()); |
259 | 246 | } else { |
260 | 247 | category = new NotepadCategory(); |
@@ -268,6 +255,15 @@ | ||
268 | 255 | |
269 | 256 | } |
270 | 257 | |
258 | + private NotepadCategory getNotepadCategory(Integer id) { | |
259 | + NotepadCategory category = categoryService.getCategory(id); | |
260 | + if (category == null) { | |
261 | + throw new ActionMessagesException("errors.could_not_find_category", | |
262 | + new Object[] { id }); | |
263 | + } | |
264 | + return category; | |
265 | + } | |
266 | + | |
271 | 267 | /** |
272 | 268 | * @return the request |
273 | 269 | */ |
@@ -111,6 +111,11 @@ | ||
111 | 111 | |
112 | 112 | @Execute(validator = false, input = "error.jsp") |
113 | 113 | public String createpage() { |
114 | + List<NotepadCategory> categoryList = getEditableCategoryItems(); | |
115 | + if (categoryList == null || categoryList.isEmpty()) { | |
116 | + throw new ActionMessagesException("errors.need_to_create_category"); | |
117 | + } | |
118 | + | |
114 | 119 | // page navi |
115 | 120 | notepadForm.initialize(); |
116 | 121 | notepadForm.mode = NotepadConstants.CREATE_MODE; |
@@ -155,12 +160,7 @@ | ||
155 | 160 | if (notepadForm.id == null) { |
156 | 161 | throw new ActionMessagesException("errors.invalid.id"); |
157 | 162 | } |
158 | - Notepad notepad = notepadService.getNotepad(Long | |
159 | - .parseLong(notepadForm.id)); | |
160 | - if (notepad == null) { | |
161 | - throw new ActionMessagesException("errors.could_not_find_notepad", | |
162 | - new Object[] { notepadForm.id }); | |
163 | - } | |
163 | + Notepad notepad = getNotepad(Long.parseLong(notepadForm.id)); | |
164 | 164 | try { |
165 | 165 | notepadService.moveDown(notepad); |
166 | 166 | NotepadUtil.addMessage(request, "success.move_notepad_down"); |
@@ -178,12 +178,7 @@ | ||
178 | 178 | if (notepadForm.id == null) { |
179 | 179 | throw new ActionMessagesException("errors.invalid.id"); |
180 | 180 | } |
181 | - Notepad notepad = notepadService.getNotepad(Long | |
182 | - .parseLong(notepadForm.id)); | |
183 | - if (notepad == null) { | |
184 | - throw new ActionMessagesException("errors.could_not_find_notepad", | |
185 | - new Object[] { notepadForm.id }); | |
186 | - } | |
181 | + Notepad notepad = getNotepad(Long.parseLong(notepadForm.id)); | |
187 | 182 | try { |
188 | 183 | notepadService.moveUp(notepad); |
189 | 184 | NotepadUtil.addMessage(request, "success.move_notepad_up"); |
@@ -259,12 +254,7 @@ | ||
259 | 254 | private void loadNotepad() { |
260 | 255 | Long notepadId = Long.parseLong(notepadForm.id); |
261 | 256 | |
262 | - Notepad notepad = notepadService.getNotepad(notepadId); | |
263 | - if (notepad == null) { | |
264 | - // throw an exception | |
265 | - throw new ActionMessagesException("errors.could_not_find_notepad", | |
266 | - new Object[] { notepadId }); | |
267 | - } | |
257 | + Notepad notepad = getNotepad(notepadId); | |
268 | 258 | notepadDxo.convertFromNotepadToForm(notepad, notepadForm); |
269 | 259 | |
270 | 260 | } |
@@ -273,7 +263,7 @@ | ||
273 | 263 | Notepad notepad; |
274 | 264 | if (notepadForm.mode == NotepadConstants.EDIT_MODE) { |
275 | 265 | Long notepadId = Long.parseLong(notepadForm.id); |
276 | - notepad = notepadService.getNotepad(notepadId); | |
266 | + notepad = getNotepad(notepadId); | |
277 | 267 | notepad.setUpdatedBy(request.getRemoteUser()); |
278 | 268 | } else { |
279 | 269 | notepad = new Notepad(); |
@@ -306,8 +296,7 @@ | ||
306 | 296 | String type = notepadForm.type; |
307 | 297 | if (type != null) { |
308 | 298 | if (NotepadConstants.PRIVATE_CATEGORY.equals(type) |
309 | - || NotepadConstants.PUBLIC_CATEGORY.equals(type) | |
310 | - || NotepadConstants.DEFAULT_CATEGORY.equals(type)) { | |
299 | + || NotepadConstants.PUBLIC_CATEGORY.equals(type)) { | |
311 | 300 | String userId = request.getRemoteUser(); |
312 | 301 | if (userId != null && userId.equals(notepadForm.createdBy)) { |
313 | 302 | return true; |
@@ -319,6 +308,31 @@ | ||
319 | 308 | return false; |
320 | 309 | } |
321 | 310 | |
311 | + private Notepad getNotepad(Long id) { | |
312 | + Notepad notepad = notepadService.getNotepad(id); | |
313 | + if (notepad == null) { | |
314 | + // throw an exception | |
315 | + throw new ActionMessagesException("errors.could_not_find_notepad", | |
316 | + new Object[] { id }); | |
317 | + } | |
318 | + if (notepad.getCategoryId() == null | |
319 | + || NotepadConstants.PRIVATE_CATEGORY.equals(notepad | |
320 | + .getNotepadCategory().getType())) { | |
321 | + if (!notepad.getCreatedBy().equals(getUserId())) { | |
322 | + throw new ActionMessagesException( | |
323 | + "errors.no_permission_for_notepad", new Object[] { id }); | |
324 | + } | |
325 | + return notepad; | |
326 | + } else if (NotepadConstants.PUBLIC_CATEGORY.equals(notepad | |
327 | + .getNotepadCategory().getType()) | |
328 | + || NotepadConstants.SHARED_CATEGORY.equals(notepad | |
329 | + .getNotepadCategory().getType())) { | |
330 | + return notepad; | |
331 | + } | |
332 | + throw new ActionMessagesException("errors.illegal_state_for_notepad", | |
333 | + new Object[] { id }); | |
334 | + } | |
335 | + | |
322 | 336 | public String getUserId() { |
323 | 337 | return request.getRemoteUser(); |
324 | 338 | } |
@@ -140,12 +140,8 @@ | ||
140 | 140 | if (categoryForm.id == null) { |
141 | 141 | throw new ActionMessagesException("errors.invalid.id"); |
142 | 142 | } |
143 | - NotepadCategory category = categoryService.getCategory(Integer | |
143 | + NotepadCategory category = getNotepadCategory(Integer | |
144 | 144 | .parseInt(categoryForm.id)); |
145 | - if (category == null) { | |
146 | - throw new ActionMessagesException("errors.could_not_find_category", | |
147 | - new Object[] { categoryForm.id }); | |
148 | - } | |
149 | 145 | try { |
150 | 146 | categoryService.moveDown(category); |
151 | 147 | NotepadUtil.addMessage(request, "success.move_category_down"); |
@@ -164,12 +160,8 @@ | ||
164 | 160 | if (categoryForm.id == null) { |
165 | 161 | throw new ActionMessagesException("errors.invalid.id"); |
166 | 162 | } |
167 | - NotepadCategory category = categoryService.getCategory(Integer | |
163 | + NotepadCategory category = getNotepadCategory(Integer | |
168 | 164 | .parseInt(categoryForm.id)); |
169 | - if (category == null) { | |
170 | - throw new ActionMessagesException("errors.could_not_find_category", | |
171 | - new Object[] { categoryForm.id }); | |
172 | - } | |
173 | 165 | try { |
174 | 166 | categoryService.moveUp(category); |
175 | 167 | NotepadUtil.addMessage(request, "success.move_category_up"); |
@@ -240,12 +232,7 @@ | ||
240 | 232 | private void loadCategory() { |
241 | 233 | Integer categoryId = Integer.parseInt(categoryForm.id); |
242 | 234 | |
243 | - NotepadCategory category = categoryService.getCategory(categoryId); | |
244 | - if (category == null) { | |
245 | - // throw an exception | |
246 | - throw new ActionMessagesException("errors.could_not_find_category", | |
247 | - new Object[] { categoryId }); | |
248 | - } | |
235 | + NotepadCategory category = getNotepadCategory(categoryId); | |
249 | 236 | categoryDxo.convertFromCategoryToForm(category, categoryForm); |
250 | 237 | |
251 | 238 | } |
@@ -254,7 +241,7 @@ | ||
254 | 241 | NotepadCategory category; |
255 | 242 | if (categoryForm.mode == NotepadConstants.EDIT_MODE) { |
256 | 243 | Integer categoryId = Integer.parseInt(categoryForm.id); |
257 | - category = categoryService.getCategory(categoryId); | |
244 | + category = getNotepadCategory(categoryId); | |
258 | 245 | category.setUpdatedBy(request.getRemoteUser()); |
259 | 246 | } else { |
260 | 247 | category = new NotepadCategory(); |
@@ -268,6 +255,24 @@ | ||
268 | 255 | |
269 | 256 | } |
270 | 257 | |
258 | + private NotepadCategory getNotepadCategory(Integer id) { | |
259 | + NotepadCategory category = categoryService.getCategory(id); | |
260 | + if (category == null) { | |
261 | + throw new ActionMessagesException("errors.could_not_find_category", | |
262 | + new Object[] { id }); | |
263 | + } | |
264 | + if (!category.getCreatedBy().equals(getUserId())) { | |
265 | + throw new ActionMessagesException( | |
266 | + "errors.no_permission_for_notepadcategory", | |
267 | + new Object[] { id }); | |
268 | + } | |
269 | + return category; | |
270 | + } | |
271 | + | |
272 | + private String getUserId() { | |
273 | + return request.getRemoteUser(); | |
274 | + } | |
275 | + | |
271 | 276 | /** |
272 | 277 | * @return the request |
273 | 278 | */ |
@@ -1,6 +1,5 @@ | ||
1 | 1 | package jp.sf.pal.notepad.pager; |
2 | 2 | |
3 | -import jp.sf.pal.notepad.NotepadConstants; | |
4 | 3 | import jp.sf.pal.notepad.common.pager.DefaultPager; |
5 | 4 | |
6 | 5 | public class NotepadPager extends DefaultPager { |
@@ -13,7 +12,7 @@ | ||
13 | 12 | |
14 | 13 | public NotepadPager() { |
15 | 14 | createdBy = null; |
16 | - categoryId = NotepadConstants.DEFAULT_CATEGORY_ID; | |
15 | + categoryId = null; | |
17 | 16 | } |
18 | 17 | |
19 | 18 | protected int getDefaultPageSize() { |
@@ -25,7 +24,13 @@ | ||
25 | 24 | } |
26 | 25 | |
27 | 26 | public void setCategoryId(Integer categoryId) { |
28 | - this.categoryId = categoryId; | |
27 | + if (categoryId != null) { | |
28 | + if (categoryId.intValue() > 0) { | |
29 | + this.categoryId = categoryId; | |
30 | + return; | |
31 | + } | |
32 | + } | |
33 | + this.categoryId = null; | |
29 | 34 | } |
30 | 35 | |
31 | 36 | public String getCreatedBy() { |