KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > blogs > actions > BlogDefinitionNames


1 /*
2  * ____.
3  * __/\ ______| |__/\. _______
4  * __ .____| | \ | +----+ \
5  * _______| /--| | | - \ _ | : - \_________
6  * \\______: :---| : : | : | \________>
7  * |__\---\_____________:______: :____|____:_____\
8  * /_____|
9  *
10  * . . . i n j a h i a w e t r u s t . . .
11  *
12  *
13  *
14  * ----- BEGIN LICENSE BLOCK -----
15  * Version: JCSL 1.0
16  *
17  * The contents of this file are subject to the Jahia Community Source License
18  * 1.0 or later (the "License"); you may not use this file except in
19  * compliance with the License. You may obtain a copy of the License at
20  * http://www.jahia.org/license
21  *
22  * Software distributed under the License is distributed on an "AS IS" basis,
23  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
24  * for the rights, obligations and limitations governing use of the contents
25  * of the file. The Original and Upgraded Code is the Jahia CMS and Portal
26  * Server. The developer of the Original and Upgraded Code is JAHIA Ltd. JAHIA
27  * Ltd. owns the copyrights in the portions it created. All Rights Reserved.
28  *
29  * The Shared Modifications are Jahia View Helper.
30  *
31  * The Developer of the Shared Modifications is Jahia Solution Sàrl.
32  * Portions created by the Initial Developer are Copyright (C) 2002 by the
33  * Initial Developer. All Rights Reserved.
34  *
35  * ----- END LICENSE BLOCK -----
36  */

37
38 package org.jahia.blogs.actions;
39
40 import org.jahia.params.ParamBean;
41
42 import java.io.FileInputStream JavaDoc;
43 import java.io.IOException JavaDoc;
44 import java.io.File JavaDoc;
45
46 import java.util.Properties JavaDoc;
47
48 import org.apache.log4j.Logger;
49
50 /**
51  *
52  <content:declareContainerList name="entries" title="List of entries">
53  <content:declareContainer>
54     <content:declareField name="title" title="Title" type="SmallText"
55         titleKey="blog.title" bundleKey="<%=resBundleID%>"/>
56     <content:declareField name="body" title="Body" type="BigText"
57         titleKey="blog.body" bundleKey="<%=resBundleID%>"/>
58     <content:declareField name="attachement" title="Attachment associated" type="File"
59         titleKey="blog.attachement" bundleKey="<%=resBundleID%>"/>
60     <content:declareField name="date" title="Date" type="Date" value="<jahia_calendar[dd.mm.yyyy / HH:MM]>"
61         titleKey="blog.date" bundleKey="<%=resBundleID%>"/>
62     <content:declareField name="author" title="Author" type="SharedSmallText"
63         value="<%=jData.params().getUser().getUsername()%>"
64         titleKey="blog.author" bundleKey="<%=resBundleID%>"/>
65     <content:declareField name="excerpt"
66             title="The Excerpt of this post" type="BigText" />
67     <content:declareField name="keyWords"
68             title="Comma seperated Keywords for this post" type="SmallText" />
69
70     <content:declareContainerList name="comments" title="List of comments">
71     <content:declareContainer>
72         <content:declareField name="author" title="Name of the author" type="SharedSmallText"
73             titleKey="blog.commentAuthor" bundleKey="<%=resBundleID%>"
74             value="<%=jData.params().getUser().getUsername()%>"/>
75         <content:declareField name="title" title="Title of this comment" type="SmallText"
76             titleKey="blog.commentTitle" bundleKey="<%=resBundleID%>"/>
77         <content:declareField name="body" title="Body of this comment" type="BigText"
78             titleKey="blog.commentBody" bundleKey="<%=resBundleID%>"/>
79         <content:declareField name="date" title="Date" type="Date"
80             value="<jahia_calendar[dd.mm.yyyy / HH:MM]>"
81             titleKey="blog.commentDate" bundleKey="<%=resBundleID%>"/>
82     </content:declareContainer>
83     </content:declareContainerList>
84
85     <content:declareContainerList name="trackBackPingURLs"
86         title="List of TrackBacks Ping URLs">
87     <content:declareContainer>
88         <content:declareField name="pingURL"
89             title="URL to send the ping to" type="SharedSmallText" />
90     </content:declareContainer>
91     </content:declareContainerList>
92
93     <content:declareContainerList name="trackbacks"
94         title="List of MovableType TrackBacks Ping data">
95     <content:declareContainer>
96         <content:declareField name="trackBackTitle"
97             title="Title of the blog entry sent in the ping" type="SharedSmallText"/>
98         <content:declareField name="trackBackExcerpt"
99             title="Excerpt of the blog entry for this trackback." type="BigText"/>
100         <content:declareField name="trackBackUrl"
101             title="Url (permalink) of the blog entry for this trackback" type="SharedSmallText"/>
102         <content:declareField name="trackBackBlog_name"
103             title="Name of the blog for this trackback" type="SharedSmallText"/>
104         <content:declareField name="trackBackPing_IP"
105             title="The IP address of the host that sent the ping" type="SharedSmallText"/>
106     </content:declareContainer>
107     </content:declareContainerList>
108
109   </content:declareContainer>
110   </content:declareContainerList>
111
112  * Simple class holding containerlist & field definition names.
113  *
114  * @author Xavier Lawrence
115  */

116 public class BlogDefinitionNames {
117     
118     // log4j logger
119
static Logger log = Logger.getLogger(BlogDefinitionNames.class);
120     
121     public static final String JavaDoc RELATIVE_PATH = "/WEB-INF/etc/config/blogs.properties";
122     
123     public static final String JavaDoc BLOG_POSTS_LIST_NAME = "postContainerList";
124     public static final String JavaDoc POST_TITLE = "postTitle";
125     public static final String JavaDoc POST_BODY = "postBody";
126     public static final String JavaDoc POST_DATE = "postDate";
127     public static final String JavaDoc POST_AUTHOR = "postAuthor";
128     public static final String JavaDoc POST_EXCERPT = "postExcerpt";
129     public static final String JavaDoc POST_KEYWORDS= "postKeyWords";
130
131     public static final String JavaDoc BLOG_TB_PING_LIST = "tbPings";
132     public static final String JavaDoc TB_PING_URL = "tbPingURL";
133     
134     public static final String JavaDoc BLOG_TB_LIST = "postTB_Pings";
135     public static final String JavaDoc TB_URL = "trackBackUrl";
136     public static final String JavaDoc TB_TITLE = "trackBackTitle";
137     public static final String JavaDoc TB_BLOG_NAME = "trackBackBlogName";
138     public static final String JavaDoc TB_EXCERPT = "trackBackExcerpt";
139     public static final String JavaDoc TB_PING_IP = "pingIP";
140     
141     private Properties JavaDoc names;
142     private ParamBean jParams;
143     
144     /** Creates a new instance of BlogDefinitionNames */
145     public BlogDefinitionNames(ParamBean jParams) {
146         try {
147             this.jParams = jParams;
148             names = new Properties JavaDoc();
149             load();
150             
151         } catch (IOException JavaDoc e) {
152             e.printStackTrace();
153         }
154     }
155     
156     /**
157      * Loads the definition names and values
158      */

159     private void load() throws IOException JavaDoc {
160         
161         FileInputStream JavaDoc fis = new FileInputStream JavaDoc(getFile());
162         names.load(fis);
163         fis.close();
164                 
165 // names.setProperty(BLOG_POSTS_LIST_NAME, "entries");
166
// names.setProperty(BLOG_TB_LIST, "trackbacks");
167
// names.setProperty(BLOG_TB_PING_LIST, "trackBackPingURLs");
168
//
169
// names.setProperty(POST_TITLE, "title");
170
// names.setProperty(POST_BODY, "body");
171
// names.setProperty(POST_DATE, "date");
172
// names.setProperty(POST_AUTHOR, "author");
173
// names.setProperty(POST_EXCERPT, "excerpt");
174
// names.setProperty(POST_KEYWORDS, "keyWords");
175
//
176
// names.setProperty(TB_PING_URL, "pingURL");
177
//
178
// names.setProperty(TB_URL, "trackBackUrl");
179
// names.setProperty(TB_TITLE, "trackBackTitle");
180
// names.setProperty(TB_BLOG_NAME, "trackBackBlog_name");
181
// names.setProperty(TB_EXCERPT, "trackBackExcerpt");
182
// names.setProperty(TB_PING_IP, "trackBackPing_IP");
183
}
184     
185     /**
186      * Returns the value of a given definition name
187      */

188     public String JavaDoc getValue(String JavaDoc name) {
189         return names.getProperty(name);
190     }
191     
192     /**
193      * returns the properties file
194      */

195     private File JavaDoc getFile() throws IOException JavaDoc {
196         return new File JavaDoc(jParams.settings().getPathResolver().
197                 resolvePath(RELATIVE_PATH));
198     }
199 }
200
Popular Tags