01: package org.contineo.web.admin;
02:
03: import org.apache.commons.logging.Log;
04: import org.apache.commons.logging.LogFactory;
05:
06: import org.contineo.util.Context;
07: import org.contineo.util.config.SettingsConfig;
08:
09: import org.contineo.web.SessionManagement;
10: import org.contineo.web.i18n.Messages;
11:
12: /**
13: * Form for directories editing
14: *
15: * @author Marco Meschieri
16: * @version $Id:$
17: * @since ###release###
18: */
19: public class FoldersForm {
20: protected static Log log = LogFactory.getLog(FoldersForm.class);
21: private String docDir = "";
22: private String indexDir = "";
23: private String userDir = "";
24:
25: public FoldersForm() {
26: reload();
27: }
28:
29: public String getDocDir() {
30: return docDir;
31: }
32:
33: public void setDocDir(String docDir) {
34: this .docDir = docDir;
35: }
36:
37: public String getIndexDir() {
38: return indexDir;
39: }
40:
41: public void setIndexDir(String indexDir) {
42: this .indexDir = indexDir;
43: }
44:
45: public String getUserDir() {
46: return userDir;
47: }
48:
49: public void setUserDir(String userDir) {
50: this .userDir = userDir;
51: }
52:
53: private void reload() {
54: SettingsConfig conf = (SettingsConfig) Context.getInstance()
55: .getBean(SettingsConfig.class);
56: docDir = conf.getValue("docdir");
57: indexDir = conf.getValue("indexdir");
58: userDir = conf.getValue("userdir");
59: }
60:
61: public String save() {
62: if (SessionManagement.isValid()) {
63: try {
64: SettingsConfig conf = (SettingsConfig) Context
65: .getInstance().getBean(SettingsConfig.class);
66: conf.setValue("docdir", docDir);
67: conf.setValue("indexdir", indexDir);
68: conf.setValue("userdir", userDir);
69:
70: boolean stored = conf.write();
71:
72: if (stored) {
73: Messages
74: .addLocalizedInfo("msg.action.savesettings");
75: }
76: } catch (Exception e) {
77: log.error(e.getMessage(), e);
78: Messages
79: .addLocalizedError("errors.action.savesettings");
80: }
81: } else {
82: return "login";
83: }
84:
85: reload();
86:
87: return null;
88: }
89: }
|