1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.plugin;
17
18 import java.util.Locale;
19 import java.util.MissingResourceException;
20 import java.util.ResourceBundle;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.seasar.tuigwaa.cms.core.CmsConstants;
25 import org.seasar.tuigwaa.cms.core.Resource;
26
27 import com.isenshi.util.CharUtil;
28
29 public class PluginUtils {
30
31 private static final String PATH_PLUGINRESOURCE = "org.seasar.tuigwaa.plugin.plugin";
32
33 private static ResourceBundle resource;
34
35 private static Log log = LogFactory.getLog(AbstractPlugin.class);
36
37 static {
38 try {
39 Locale locale = Locale.getDefault();
40 resource = ResourceBundle.getBundle(PATH_PLUGINRESOURCE, locale);
41 } catch (MissingResourceException mre) {
42 log.error("resource not found.");
43 }
44 }
45
46 public static final String getMessage(String key) {
47 if (resource == null) {
48 return null;
49 }
50
51 String msg = null;
52
53 try {
54 msg = resource.getString(key);
55 } catch (Exception e) {
56 log.error("error occured during reading " + key);
57 }
58
59 return msg;
60 }
61
62 public static final boolean isAttachment(Resource res){
63 String pagePath = res.getPath();
64 pagePath = CharUtil.chartrim(pagePath, '/');
65 return res.isFolder() && pagePath.endsWith(CmsConstants.ATTACHEMENT_SUFFIX);
66 }
67
68
69
70 }