1
2
3
4
5
6 package org.repoweb.action;
7 import javax.servlet.http.HttpServletRequest;
8 import javax.servlet.http.HttpServletResponse;
9 import org.apache.struts.action.Action;
10 import org.apache.struts.action.ActionForm;
11 import org.apache.struts.action.ActionForward;
12 import org.apache.struts.action.ActionMapping;
13 import org.repoweb.model.Manager;
14 import org.repoweb.model.Repository;
15 /***
16 * Find by groupId (or All) groups defined in the repository.
17 *
18 * <p><b>IN</b></p>
19 *
20 * <ul>
21 * <li><code>QuickFind.SEARCH_VALUE</code> (request/optional): the
22 * pattern to search for. </li>
23 * </ul>
24 *
25 * <p><b>OUT</b></p>
26 *
27 * <ul>
28 * <li><code>FindGroup.RESULT</code> (request): result of the search. </li>
29 * </ul>
30 */
31 public class FindGroup extends Action {
32 public static final String RESULT = "result";
33
34 public ActionForward execute(ActionMapping mapping, ActionForm objForm,
35 HttpServletRequest request, HttpServletResponse res) {
36 Repository repo = Manager.getRepository();
37
38 String searchPattern = request.getParameter(QuickFind.SEARCH_VALUE);
39
40 if (searchPattern != null && !"".equals(searchPattern.trim())) {
41 request.setAttribute(RESULT, repo.findGroups(searchPattern.trim()));
42 }
43 else {
44 request.setAttribute(RESULT, repo.getAllGroups());
45 }
46
47 return mapping.findForward("success");
48 }
49 }