1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.util;
17
18 import java.util.Date;
19
20 import org.seasar.tuigwaa.system.Constants;
21
22 /***
23 * @author nishioka
24 */
25 public class TgwPathResolver {
26
27 private static final String SEP = System.getProperty("file.separator");
28
29 private static final String BACKUP_FILENAME = "table.dicon";
30
31 private static final String SITECONFIG_FILENAME = "config.xml";
32
33 private static final String LOGIC_FILENAME = "logic.dicon";
34
35 public static final String getSiteDirectory(String siteName) {
36 return Constants.DIRECTORY_APP + siteName;
37 }
38
39 public static final String getSiteConfigFilePath(String siteName) {
40 return Constants.DIRECTORY_APP + siteName + "/" + SITECONFIG_FILENAME;
41 }
42
43 public static final String getSiteBackupDirPath(String siteName) {
44 return getSiteBackupDirPath(siteName, (String) null);
45 }
46
47 public static final String getSiteBackupDirPath(String siteName,
48 String backupDate) {
49 String dir = Constants.DIRECTORY_APP + siteName + "/"
50 + Constants.DIRECTORY_BACKUP;
51 if (backupDate == null) {
52 return dir;
53 }
54 return dir + backupDate + "/";
55 }
56
57 public static final String getSiteBackupDirPath(String siteName,
58 Date backupDate) {
59 String dateStr = Constants.SIMPLE_DATEFORMAT.format(backupDate);
60 return getSiteBackupDirPath(siteName, dateStr);
61 }
62
63 public static final String getLogicFilePath(String siteName) {
64 return Constants.DIRECTORY_APP + siteName + "/" + LOGIC_FILENAME;
65 }
66
67 public static final String getDaoFilePath(String domain, String entityName) {
68 return Constants.DIRECTORY_APP + domain + "/dao/" + entityName
69 + ".dicon";
70 }
71
72 public static final String getExternalConfig(String siteName) {
73 return Constants.DIRECTORY_APP + siteName + "/ext/struts-config.xml";
74 }
75
76 public static final String getExternalLogicDicon(String siteName) {
77 return Constants.DIRECTORY_APP + siteName + "/ext/logic.dicon";
78 }
79
80 public static final String getExternalPluginDicon(String siteName) {
81 return Constants.DIRECTORY_APP + siteName + "/ext/plugin.dicon";
82 }
83
84 public static final String getDatabaseBackupFilePath(String dirname) {
85 return dirname + BACKUP_FILENAME;
86 }
87
88 public static final String getTableBackupFilePath(String targetdir,
89 String tablename) {
90 return targetdir + SEP + tablename + ".csv";
91 }
92
93 public static final String getDatabaseFilePath(String name) {
94 return Constants.DIRECTORY_APP + name + ".db";
95 }
96
97 public static final String getTmpUploadFilePath(String siteName,
98 String tmpDir, String fileName) {
99 return Constants.DIRECTORY_TMP + Constants.DIRECTORY_UPLOAD + siteName
100 + "/" + tmpDir + "/" + fileName;
101 }
102
103 public static final String getTemplatePath(String siteName,
104 String entityName, String type, String name, String option) {
105 String path = Constants.DIRECTORY_APP + siteName + "/template/"
106 + entityName + "/" + type;
107
108 if (option != null && option.length() > 0) {
109 path += "/" + option;
110 }
111
112 if (name != null && name.length() > 0) {
113 return path + "/" + name + ".vm";
114 } else {
115 return path;
116 }
117 }
118 }