1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.ginp.commands;
20
21 import java.util.Vector;
22
23 import net.sf.ginp.CommandParameter;
24 import net.sf.ginp.GinpModel;
25 import net.sf.ginp.config.Configuration;
26 import org.apache.log4j.Logger;
27
28 /**
29 * Select the current collection and folder position.
30 *
31 *@author Doug Culnane
32 *@version $Revision: 264 $
33 */
34 public class SelectPath implements Command {
35
36 private static Logger log = Logger.getLogger(SelectPath.class);
37
38 /**
39 * PicCollection id (colid) and path (path) should be sent in the parameters
40 * so that the model is not out of sync with browser. This can happen due
41 * to use of the Back Button.
42 *
43 *@param model Description of the Parameter
44 *@param params Description of the Parameter
45 */
46 public void action(GinpModel model, Vector params) {
47
48 String path = "";
49
50 for (int i = 0; i < params.size(); i++) {
51 CommandParameter param = (CommandParameter) params.get(i);
52 if (param.getName().equals("path")) {
53 path = param.getValue();
54 } else if (param.getName().equals("colid")) {
55 try {
56 int id = (new Integer(param.getValue())).intValue();
57 model.setCurrectCollection(id);
58 } catch (Exception ex) {
59 log.error(ex);
60 }
61 }
62 }
63 model.getCollection().setPath(path);
64 model.setCurrentPage(Configuration.getCollectionPageName());
65 model.setPageOffset(0);
66 model.setPagePosition(0);
67 }
68 }
69