1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.sf.ginp.tags;
22
23 import java.io.File;
24 import java.io.FileReader;
25 import java.io.LineNumberReader;
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.jsp.JspException;
28 import javax.servlet.jsp.JspTagException;
29 import net.sf.ginp.GinpModel;
30 import net.sf.ginp.config.ModelUtil;
31 import net.sf.ginp.util.StringTool;
32 import org.apache.commons.logging.Log;
33 import org.apache.commons.logging.LogFactory;
34
35 /**
36 * For the Current PicCollection's currently selected Folder retrieve information
37 * from the ginpfolder.xml data file.
38 *
39 *@author doc
40 */
41 public class GetFolderInfo extends javax.servlet.jsp.tagext.TagSupport
42 implements javax.servlet.jsp.tagext.IterationTag {
43
44 private GinpModel model;
45 private Log log = LogFactory.getLog(GetFolderInfo.class);
46
47
48 /**
49 * Description of the Method
50 *
51 *@return Description of the Return Value
52 *@exception JspException Description of the Exception
53 */
54 public int doStartTag() throws JspException {
55
56 String title = "";
57 String description = "";
58 String date = "";
59 String time = "";
60
61 try {
62 model = ModelUtil.getModel((HttpServletRequest) pageContext.getRequest());
63 } catch (Exception e) {
64 throw new JspException(e);
65 }
66 try {
67 File fl = new File(model.getCollection().getRoot()
68 + model.getCollection().getPath() + "ginpfolder.xml");
69 if (fl.exists()) {
70 FileReader fr = new FileReader(fl);
71 LineNumberReader lr = new LineNumberReader(fr);
72 StringBuffer sb = new StringBuffer();
73 String temp;
74
75 while ((temp = lr.readLine()) != null) {
76 sb.append(temp + "\n");
77 }
78
79
80 date = StringTool.getXMLTagContent("date", sb.toString());
81 if (date != null) {
82 pageContext.setAttribute("date", date);
83 } else {
84 pageContext.setAttribute("date", "");
85 }
86
87
88 time = StringTool.getXMLTagContent("time", sb.toString());
89 if (time != null) {
90 pageContext.setAttribute("time", time);
91 } else {
92 pageContext.setAttribute("time", "");
93 }
94
95
96 temp = StringTool.getXMLTagContent("title", sb.toString());
97 title = StringTool.getXMLTagContent(
98 model.getLocale().getLanguage(), temp);
99 if (title != null) {
100 pageContext.setAttribute("title", title);
101 } else {
102 pageContext.setAttribute("title", "");
103 }
104
105
106 temp = StringTool.getXMLTagContent("description", sb.toString());
107 description = StringTool.getXMLTagContent(
108 model.getLocale().getLanguage(), temp);
109 if (description != null) {
110 pageContext.setAttribute("description", description);
111 } else {
112 pageContext.setAttribute("description", "");
113 }
114
115 pageContext.setAttribute("path", model.getCollection().getPath());
116 pageContext.setAttribute("colid", "" + model.getCurrCollectionId());
117 pageContext.setAttribute("langcode", "" + model.getLocale().getLanguage());
118
119 return EVAL_BODY_AGAIN;
120 } else {
121 return SKIP_BODY;
122 }
123 } catch (Exception ex) {
124 return SKIP_BODY;
125 }
126 }
127 }
128
129