View Javadoc

1   /*
2    *  ginp - Java Web Application for Viewing Photo Collections
3    *  Copyright (C) 2004  Douglas John Culnane <doug@culnane.net>
4    *
5    *  This library is free software; you can redistribute it and/or
6    *  modify it under the terms of the GNU Lesser General Public
7    *  License as published by the Free Software Foundation; either
8    *  version 2.1 of the License, or any later version.
9    *
10   *  This library is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   *  Lesser General Public License for more details.
14   *
15   *  You should have received a copy of the GNU Lesser General Public
16   *  License along with this library; if not, write to the Free Software
17   *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18   */
19  package net.sf.ginp.commands;
20  
21  import net.sf.ginp.CommandParameter;
22  import net.sf.ginp.GinpModel;
23  import net.sf.ginp.config.Configuration;
24  
25  import java.util.Vector;
26  /**
27   *  Class to collect and write folder and picture data to xml data files.
28   *
29   *@author     Doug Culnane
30   *@version    $Revision: 287 $
31   */
32  public class SetConfiguration implements Command {
33  
34      /**
35       *  Description of the Method
36       *
37       *@param  model   Description of the Parameter
38       *@param  params  Description of the Parameter
39       */
40      public void action(GinpModel model, Vector params) {
41  
42          // admin user only
43          if (model.getUserName().equals("admin")) {
44  
45              String  adminpassword        = "";
46              String  adminpasswordrepeat  = "";
47              
48              Configuration.writeConfig();
49              
50              for (int i = 0; i < params.size(); i++) {
51                  CommandParameter  param  = (CommandParameter) params.get(i);
52  
53                  if (param.getName().equals("thumbsize")) {
54                      Configuration.setThumbSize(param.getValue());
55                  } else if (param.getName().equals("filmstripthumbsize")) {
56                      Configuration.setFilmStripThumbSize(param.getValue());
57                  } else if (param.getName().equals("picturepagename")) {
58                      Configuration.setPicturePageName(param.getValue());
59                  } else if (param.getName().equals("collectionpagename")) {
60                      Configuration.setCollectionPageName(param.getValue());
61                  } else if (param.getName().equals("characterencoding")) {
62                      Configuration.setCharacterEncoding(param.getValue());
63                  } else if (param.getName().equals("adminpassword")) {
64                      adminpassword = param.getValue();
65                  } else if (param.getName().equals("adminpasswordrepeat")) {
66                      adminpasswordrepeat = param.getValue();
67                  }
68              }
69              if (adminpassword.equals(adminpasswordrepeat)) {
70                  if (!(adminpassword.equals(""))) {
71                      Configuration.setAdminpassword(adminpassword);
72                  }
73              }
74              Configuration.writeConfig();
75          }
76  
77          // go back to setup page.
78          model.setCurrentPage("setup2.jsp");
79      }
80  }
81