1 /*
2 * PROJECT : DAR Runtime and Tools
3 * COPYRIGHT : Copyright (C) 1999-2004 tim.stephenson@enableit.org
4 * LICENSE : GNU LESSER GENERAL PUBLIC LICENSE
5 * Version 2.1, February 1999
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21 package org.enableit.db.darrt;
22
23 import java.io.File;
24
25 import org.apache.log4j.Logger;
26
27
28 /***
29 * Contains file manipulation operations common to several of the main darrt
30 * classes.
31 * @author Tim Stephenson
32 */
33 public abstract class AbstractFileHandler {
34 /***
35 * The Log4J <code>Logger</code> doing the logging.
36 */
37 private static Logger logger = Logger.getLogger(AbstractFileHandler.class);
38
39 /***
40 * CVS info ABOUT this class and its current version
41 */
42 public static final String ABOUT = "$Id: AbstractFileHandler.java,v 1.5 2004/03/19 19:27:41 tim Exp $";
43
44 /*
45 * Properties
46 */
47
48 /***
49 * The operating directory where files such as exported database
50 * definitions (see SchemaExporter) are written.
51 */
52 private File operDir;
53
54 /*
55 * Constructors
56 */
57
58 /***
59 * Default Constructor
60 */
61 public AbstractFileHandler() {
62 }
63
64 /*
65 * Methods
66 */
67
68 /***
69 * Gets operDir
70 * @return operDir
71 */
72 public File getOperDir() {
73 logger.info("METHOD_ENTRY: getOperDir");
74
75 File darrtHome = operDir;
76
77 if (darrtHome == null) {
78 /*
79 * Get temp dir. NB Cannot use javax.servlet.context.tempdir as
80 * have no access to ServletContext (may not even be in container)
81 * therefore create sudirectory of "user.home"
82 */
83 File userHome = new File(System.getProperty("user.home"));
84
85 logger.warn("Found user.home: " + userHome);
86 darrtHome = new File(userHome, "darrt");
87
88 if (!darrtHome.exists()) {
89 darrtHome.mkdirs();
90 }
91
92 operDir = darrtHome;
93 }
94
95 logger.info("METHOD_EXIT: getOperDir, returning: " + darrtHome);
96
97 return darrtHome;
98 }
99
100 /***
101 * Sets operDir
102 * @param operDir
103 */
104 public void setOperDir(File operDir) {
105 this.operDir = operDir;
106 }
107 }
This page was automatically generated by Maven