File Source: MetaWeblogAPIHandler.java
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */
18
19 package org.apache.roller.weblogger.webservices.xmlrpc;
20
21 import java.io.ByteArrayInputStream;
22 import java.sql.Timestamp;
23 import java.util.Date;
24 import java.util.Hashtable;
25 import java.util.Iterator;
26 import java.util.List;
27 import java.util.Vector;
28 import org.apache.commons.lang.StringUtils;
29 import org.apache.commons.logging.Log;
30 import org.apache.commons.logging.LogFactory;
31 import org.apache.roller.weblogger.WebloggerException;
32 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
33 import org.apache.roller.weblogger.business.FileManager;
34 import org.apache.roller.weblogger.business.Weblogger;
35 import org.apache.roller.weblogger.business.WebloggerFactory;
36 import org.apache.roller.weblogger.business.WeblogManager;
37 import org.apache.roller.weblogger.pojos.User;
38 import org.apache.roller.weblogger.pojos.WeblogCategory;
39 import org.apache.roller.weblogger.pojos.WeblogEntry;
40 import org.apache.roller.weblogger.pojos.Weblog;
41 import org.apache.roller.weblogger.util.RollerMessages;
42 import org.apache.roller.weblogger.util.Utilities;
43 import org.apache.xmlrpc.XmlRpcException;
44
45
46 /**
47 * Weblogger XML-RPC Handler for the MetaWeblog API.
48 *
49 * MetaWeblog API spec can be found at http://www.xmlrpc.com/metaWeblogApi
50 *
51 * @author David M Johnson
52 */
53 public class MetaWeblogAPIHandler extends BloggerAPIHandler {
54
55 static final long serialVersionUID = -1364456614935668629L;
56
/*
P/P * Method: org.apache.roller.weblogger.webservices.xmlrpc.MetaWeblogAPIHandler__static_init
*
* Postconditions:
* init'ed(mLogger)
*/
57 private static Log mLogger = LogFactory.getLog(MetaWeblogAPIHandler.class);
58
59 public MetaWeblogAPIHandler() {
/*
P/P * Method: void org.apache.roller.weblogger.webservices.xmlrpc.MetaWeblogAPIHandler()
*/
60 super();
61 }
62
63
64 /**
65 * Authenticates a user and returns the categories available in the website
66 *
67 * @param blogid Dummy Value for Weblogger
68 * @param userid Login for a MetaWeblog user who has permission to post to the blog
69 * @param password Password for said username
70 * @return
71 * @throws Exception
72 */
73 public Object getCategories(String blogid, String userid, String password)
74 throws Exception {
75
/*
P/P * Method: Object getCategories(String, String, String)
*
* Preconditions:
* mLogger != null
* (soft) org/apache/roller/weblogger/webservices/xmlrpc/BaseAPIHandler.mLogger != null
* (soft) password != null
*
* Presumptions:
* java.util.Iterator:next(...)@87 != null
* org.apache.roller.weblogger.business.WeblogManager:getWeblogCategories(...)@85 != null
* org.apache.roller.weblogger.business.Weblogger:getWeblogManager(...)@84 != null
* org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@81 != null
*
* Postconditions:
* return_value == &new Hashtable(getCategories#3)
* new Hashtable(getCategories#3) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@86: {0}, {1}
*/
76 mLogger.debug("getCategories() Called =====[ SUPPORTED ]=====");
77 mLogger.debug(" BlogId: " + blogid);
78 mLogger.debug(" UserId: " + userid);
79
80 Weblog website = validate(blogid, userid,password);
81 Weblogger roller = WebloggerFactory.getWeblogger();
82 try {
83 Hashtable result = new Hashtable();
84 WeblogManager weblogMgr = roller.getWeblogManager();
85 List cats = weblogMgr.getWeblogCategories(website, false);
86 for (Iterator wbcItr = cats.iterator(); wbcItr.hasNext();) {
87 WeblogCategory category = (WeblogCategory) wbcItr.next();
88 result.put(category.getPath(),
89 createCategoryStruct(category, userid));
90 }
91 return result;
92 } catch (Exception e) {
93 String msg = "ERROR in MetaWeblogAPIHandler.getCategories";
94 mLogger.error(msg,e);
95 throw new XmlRpcException(UNKNOWN_EXCEPTION, msg);
96 }
97 }
98
99
100 /**
101 * Edits a given post. Optionally, will publish the blog after making the edit
102 *
103 * @param postid Unique identifier of the post to be changed
104 * @param userid Login for a MetaWeblog user who has permission to post to the blog
105 * @param password Password for said username
106 * @param struct Contents of the post
107 * @param publish If true, the blog will be published immediately after the post is made
108 * @throws org.apache.xmlrpc.XmlRpcException
109 * @return
110 */
111 public boolean editPost(String postid, String userid, String password,
112 Hashtable struct, int publish) throws Exception {
113
/*
P/P * Method: bool editPost(String, String, String, Hashtable, int)
*
* Preconditions:
* mLogger != null
* struct != null
* (soft) org/apache/roller/weblogger/webservices/xmlrpc/BaseAPIHandler.mLogger != null
* (soft) password != null
*
* Postconditions:
* return_value == 1
*/
114 return editPost(postid, userid, password, struct, publish > 0);
115 }
116
117
118 public boolean editPost(String postid, String userid, String password,
119 Hashtable struct, boolean publish) throws Exception {
120
/*
P/P * Method: bool editPost(String, String, String, Hashtable, bool)
*
* Preconditions:
* mLogger != null
* struct != null
* (soft) org/apache/roller/weblogger/webservices/xmlrpc/BaseAPIHandler.mLogger != null
* (soft) password != null
*
* Presumptions:
* cats.length@142 >= 1
* java.lang.Boolean:valueOf(...)@156 != null
* java.util.Hashtable:get(...)@142 != null
* org.apache.roller.weblogger.business.WeblogManager:getWeblogEntry(...)@128 != null
* org.apache.roller.weblogger.business.Weblogger:getWeblogManager(...)@127 != null
* ...
*
* Postconditions:
* return_value == 1
*
* Test Vectors:
* java.lang.Boolean:booleanValue(...)@156: {0}, {1}
* java.lang.String:equals(...)@153: {1}, {0}
* java.util.Hashtable:get(...)@134: Inverse{null}, Addr_Set{null}
* java.util.Hashtable:get(...)@137: Inverse{null}, Addr_Set{null}
* java.util.Hashtable:get(...)@141: Addr_Set{null}, Inverse{null}
*/
121 mLogger.debug("editPost() Called ========[ SUPPORTED ]=====");
122 mLogger.debug(" PostId: " + postid);
123 mLogger.debug(" UserId: " + userid);
124 mLogger.debug(" Publish: " + publish);
125
126 Weblogger roller = WebloggerFactory.getWeblogger();
127 WeblogManager weblogMgr = roller.getWeblogManager();
128 WeblogEntry entry = weblogMgr.getWeblogEntry(postid);
129
130 validate(entry.getWebsite().getHandle(), userid,password);
131
132 Hashtable postcontent = struct;
133 String description = (String)postcontent.get("description");
134 String title = (String)postcontent.get("title");
135 if (title == null) title = "";
136
137 Date dateCreated = (Date)postcontent.get("dateCreated");
138 if (dateCreated == null) dateCreated = (Date)postcontent.get("pubDate");
139
140 String cat = null;
141 if ( postcontent.get("categories") != null ) {
142 Object[] cats = (Object[])postcontent.get("categories");
143 cat = (String)cats[0];
144 }
145 mLogger.debug(" Title: " + title);
146 mLogger.debug(" Category: " + cat);
147
148 try {
149
150 Timestamp current =
151 new Timestamp(System.currentTimeMillis());
152
153 if ( !title.equals("") ) entry.setTitle(title);
154 entry.setText(description);
155 entry.setUpdateTime(current);
156 if (Boolean.valueOf(publish).booleanValue()) {
157 entry.setStatus(WeblogEntry.PUBLISHED);
158 } else {
159 entry.setStatus(WeblogEntry.DRAFT);
160 }
161 if (dateCreated != null) {
162 entry.setPubTime(new Timestamp(dateCreated.getTime()));
163 }
164
+ 165 if ( cat != null ) {
166 // Use first category specified by request
+ 167 WeblogCategory cd =
168 weblogMgr.getWeblogCategoryByPath(entry.getWebsite(), cat);
169 entry.setCategory(cd);
170 }
171
172 // save the entry
173 weblogMgr.saveWeblogEntry(entry);
174 roller.flush();
175
176 // notify cache
177 flushPageCache(entry.getWebsite());
178
179 // TODO: Weblogger timestamps need better than 1 second accuracy
180 // Until then, we can't allow more than one post per second
181 Thread.sleep(1000);
182
183 return true;
184 } catch (Exception e) {
185 String msg = "ERROR in MetaWeblogAPIHandler.editPost";
186 mLogger.error(msg,e);
187 throw new XmlRpcException(UNKNOWN_EXCEPTION, msg);
188 }
189 }
190
191
192 /**
193 * Makes a new post to a designated blog. Optionally, will publish the blog after making the post
194 *
195 * @param blogid Unique identifier of the blog the post will be added to
196 * @param userid Login for a MetaWeblog user who has permission to post to the blog
197 * @param password Password for said username
198 * @param struct Contents of the post
199 * @param publish If true, the blog will be published immediately after the post is made
200 * @throws org.apache.xmlrpc.XmlRpcException
201 * @return
202 */
203 public String newPost(String blogid, String userid, String password,
204 Hashtable struct, int publish) throws Exception {
205
/*
P/P * Method: String newPost(String, String, String, Hashtable, int)
*
* Preconditions:
* mLogger != null
* struct != null
* (soft) org/apache/roller/weblogger/webservices/xmlrpc/BaseAPIHandler.mLogger != null
* (soft) password != null
*
* Postconditions:
* init'ed(return_value)
*/
206 return newPost(blogid, userid, password, struct, publish > 0);
207 }
208
209
210 public String newPost(String blogid, String userid, String password,
211 Hashtable struct, boolean publish) throws Exception {
212
/*
P/P * Method: String newPost(String, String, String, Hashtable, bool)
*
* Preconditions:
* mLogger != null
* struct != null
* (soft) org/apache/roller/weblogger/webservices/xmlrpc/BaseAPIHandler.mLogger != null
* (soft) password != null
*
* Presumptions:
* cats.length@268 <= 232-1
* java.lang.Boolean:valueOf(...)@258 != null
* java.lang.Object:getClass(...)@270 != null
* org.apache.commons.lang.StringUtils:isEmpty(...)@223 == 0
* org.apache.roller.weblogger.business.Weblogger:getUserManager(...)@239 != null
* ...
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* cats.length@268: {0}, {1..232-1}
* java.lang.Boolean:booleanValue(...)@258: {0}, {1}
* java.util.Hashtable:get(...)@231: Inverse{null}, Addr_Set{null}
* java.util.Hashtable:get(...)@267: Addr_Set{null}, Inverse{null}
* java.util.Hashtable:get(...)@268: Addr_Set{null}, Inverse{null}
* org.apache.commons.lang.StringUtils:isEmpty(...)@223: {0}, {1}
* org.apache.commons.lang.StringUtils:isEmpty(...)@227: {0}, {1}
* org.apache.roller.weblogger.business.WeblogManager:getWeblogCategoryByPath(...)@274: Addr_Set{null}, Inverse{null}
* org.apache.roller.weblogger.pojos.Weblog:getDefaultPlugins(...)@254: Addr_Set{null}, Inverse{null}
*/
213 mLogger.debug("newPost() Called ===========[ SUPPORTED ]=====");
214 mLogger.debug(" BlogId: " + blogid);
215 mLogger.debug(" UserId: " + userid);
216 mLogger.debug(" Publish: " + publish);
217
218 Weblog website = validate(blogid, userid, password);
219
220 Hashtable postcontent = struct;
221 String description = (String)postcontent.get("description");
222 String title = (String)postcontent.get("title");
223 if (StringUtils.isEmpty(title) && StringUtils.isEmpty(description)) {
224 throw new XmlRpcException(
225 BLOGGERAPI_INCOMPLETE_POST, "Must specify title or description");
226 }
227 if (StringUtils.isEmpty(title)) {
228 title = Utilities.truncateNicely(description, 15, 15, "...");
229 }
230
231 Date dateCreated = (Date)postcontent.get("dateCreated");
232 if (dateCreated == null) dateCreated = (Date)postcontent.get("pubDate");
233 if (dateCreated == null) dateCreated = new Date();
234 mLogger.debug(" Title: " + title);
235
236 try {
237 Weblogger roller = WebloggerFactory.getWeblogger();
238 WeblogManager weblogMgr = roller.getWeblogManager();
239 User user = roller.getUserManager().getUserByUserName(userid);
240 Timestamp current = new Timestamp(System.currentTimeMillis());
241
242 WeblogEntry entry = new WeblogEntry();
243 entry.setTitle(title);
244 entry.setText(description);
245 entry.setLocale(website.getLocale());
246 entry.setPubTime(new Timestamp(dateCreated.getTime()));
247 entry.setUpdateTime(current);
248 entry.setWebsite(website);
249 entry.setCreator(user);
250 entry.setCommentDays(new Integer(website.getDefaultCommentDays()));
251 entry.setAllowComments(website.getDefaultAllowComments());
252
253 // apply weblog default plugins
254 if (website.getDefaultPlugins() != null) {
255 entry.setPlugins(website.getDefaultPlugins());
256 }
257
258 if (Boolean.valueOf(publish).booleanValue()) {
259 entry.setStatus(WeblogEntry.PUBLISHED);
260 } else {
261 entry.setStatus(WeblogEntry.DRAFT);
262 }
263
264 // MetaWeblog supports multiple cats, Weblogger supports one/entry
265 // so here we take accept the first category that exists
266 WeblogCategory rollerCat = null;
267 if ( postcontent.get("categories") != null ) {
268 Object[] cats = (Object[])postcontent.get("categories");
269 if (cats != null && cats.length > 0) {
+ 270 mLogger.debug("cats type - "+cats[0].getClass().getName());
+ 271 mLogger.debug("cat to string - "+cats[0].toString());
272 for (int i=0; i<cats.length; i++) {
273 Object cat = cats[i];
274 rollerCat = weblogMgr.getWeblogCategoryByPath(website, (String)cat);
275 if (rollerCat != null) {
276 entry.setCategory(rollerCat);
277 break;
278 }
279 }
280 }
281 }
282 if (rollerCat == null) {
283 // or we fall back to the default Blogger API category
284 entry.setCategory(website.getBloggerCategory());
285 }
286
287 // save the entry
288 weblogMgr.saveWeblogEntry(entry);
289 roller.flush();
290
291 // notify cache
292 flushPageCache(entry.getWebsite());
293
294 // TODO: Weblogger timestamps need better than 1 second accuracy
295 // Until then, we can't allow more than one post per second
296 Thread.sleep(1000);
297
298 return entry.getId();
299 } catch (Exception e) {
300 String msg = "ERROR in MetaWeblogAPIHandler.newPost";
301 mLogger.error(msg,e);
302 throw new XmlRpcException(UNKNOWN_EXCEPTION, msg);
303 }
304 }
305
306
307 /**
308 *
309 * @param postid
310 * @param userid
311 * @param password
312 * @return
313 * @throws Exception
314 */
315 public Object getPost(String postid, String userid, String password)
316 throws Exception {
317
/*
P/P * Method: Object getPost(String, String, String)
*
* Preconditions:
* mLogger != null
* (soft) org/apache/roller/weblogger/webservices/xmlrpc/BaseAPIHandler.mLogger != null
* (soft) password != null
*
* Presumptions:
* org.apache.roller.weblogger.business.WeblogManager:getWeblogEntry(...)@324 != null
* org.apache.roller.weblogger.business.Weblogger:getWeblogManager(...)@323 != null
* org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@322 != null
* org.apache.roller.weblogger.pojos.WeblogEntry:getWebsite(...)@326 != null
*
* Postconditions:
* return_value == &new Hashtable(createPostStruct#2)
* new Hashtable(createPostStruct#2) num objects == 1
*/
318 mLogger.debug("getPost() Called =========[ SUPPORTED ]=====");
319 mLogger.debug(" PostId: " + postid);
320 mLogger.debug(" UserId: " + userid);
321
322 Weblogger roller = WebloggerFactory.getWeblogger();
323 WeblogManager weblogMgr = roller.getWeblogManager();
324 WeblogEntry entry = weblogMgr.getWeblogEntry(postid);
325
326 validate(entry.getWebsite().getHandle(), userid,password);
327
328 try {
329 return createPostStruct(entry, userid);
330 } catch (Exception e) {
331 String msg = "ERROR in MetaWeblogAPIHandler.getPost";
332 mLogger.error(msg,e);
333 throw new XmlRpcException(UNKNOWN_EXCEPTION, msg);
334 }
335 }
336
337
338 /**
339 * Allows user to post a binary object, a file, to Weblogger. If the file is
340 * allowed by the RollerConfig file-upload settings, then the file will be
341 * placed in the user's upload diretory.
342 */
343 public Object newMediaObject(String blogid, String userid, String password,
344 Hashtable struct) throws Exception {
345
/*
P/P * Method: Object newMediaObject(String, String, String, Hashtable)
*
* Preconditions:
* mLogger != null
* struct != null
* (soft) org/apache/roller/weblogger/webservices/xmlrpc/BaseAPIHandler.mLogger != null
* (soft) password != null
*
* Presumptions:
* bits.length@359 <= 264-1
* java.util.Hashtable:get(...)@353 != null
* java.util.Hashtable:get(...)@359 != null
* org.apache.roller.weblogger.business.Weblogger:getFileManager(...)@362 != null
* org.apache.roller.weblogger.business.Weblogger:getUrlStrategy(...)@368 != null
* ...
*
* Postconditions:
* return_value == &new Hashtable(newMediaObject#7)
* new Hashtable(newMediaObject#7) num objects == 1
*/
346 mLogger.debug("newMediaObject() Called =[ SUPPORTED ]=====");
347 mLogger.debug(" BlogId: " + blogid);
348 mLogger.debug(" UserId: " + userid);
349 mLogger.debug(" Password: *********");
350
351 Weblog website = validate(blogid, userid, password);
352 try {
353 String name = (String) struct.get("name");
354 name = name.replaceAll("/","_");
355 String type = (String) struct.get("type");
356 mLogger.debug("newMediaObject name: " + name);
357 mLogger.debug("newMediaObject type: " + type);
358
359 byte[] bits = (byte[]) struct.get("bits");
360
361 Weblogger roller = WebloggerFactory.getWeblogger();
362 FileManager fmgr = roller.getFileManager();
+ 363 RollerMessages msgs = new RollerMessages();
364
365 // Try to save file
366 fmgr.saveFile(website, name, type, bits.length, new ByteArrayInputStream(bits));
367
368 String fileLink = WebloggerFactory.getWeblogger().getUrlStrategy().getWeblogResourceURL(website, name, true);
369
370 Hashtable returnStruct = new Hashtable(1);
371 returnStruct.put("url", fileLink);
372 return returnStruct;
373
374 } catch (WebloggerException e) {
375 String msg = "ERROR in MetaWeblogAPIHandler.newMediaObject";
376 mLogger.error(msg,e);
377 throw new XmlRpcException(UNKNOWN_EXCEPTION, msg);
378 }
379 }
380
381
382 /**
383 * Get a list of recent posts for a category
384 *
385 * @param blogid Unique identifier of the blog the post will be added to
386 * @param userid Login for a Blogger user who has permission to post to the blog
387 * @param password Password for said username
388 * @param numposts Number of Posts to Retrieve
389 * @throws XmlRpcException
390 * @return
391 */
392 public Object getRecentPosts(String blogid, String userid, String password,
393 int numposts) throws Exception {
394
/*
P/P * Method: Object getRecentPosts(String, String, String, int)
*
* Preconditions:
* mLogger != null
* (soft) org/apache/roller/weblogger/webservices/xmlrpc/BaseAPIHandler.mLogger != null
* (soft) password != null
*
* Presumptions:
* java.util.Iterator:next(...)@424 != null
* org.apache.roller.weblogger.business.WeblogManager:getWeblogEntries(...)@408 != null
* org.apache.roller.weblogger.business.Weblogger:getWeblogManager(...)@406 != null
* org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@405 != null
*
* Postconditions:
* return_value == &new Vector(getRecentPosts#4)
* new Vector(getRecentPosts#4) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@423: {0}, {1}
*/
395 mLogger.debug("getRecentPosts() Called ===========[ SUPPORTED ]=====");
396 mLogger.debug(" BlogId: " + blogid);
397 mLogger.debug(" UserId: " + userid);
398 mLogger.debug(" Number: " + numposts);
399
400 Weblog website = validate(blogid, userid,password);
401
402 try {
403 Vector results = new Vector();
404
405 Weblogger roller = WebloggerFactory.getWeblogger();
406 WeblogManager weblogMgr = roller.getWeblogManager();
+ 407 if (website != null) {
408 List entries = weblogMgr.getWeblogEntries(
409 website, // website
410 null,
411 null, // startDate
412 null, // endDate
413 null, // catName
414 null, // tags
415 null, // status
416 null, // text
417 "updateTime", // sortby
418 null,
419 null,
420 0, numposts);
421
422 Iterator iter = entries.iterator();
423 while (iter.hasNext()) {
424 WeblogEntry entry = (WeblogEntry)iter.next();
425 results.addElement(createPostStruct(entry, userid));
426 }
427 }
428 return results;
429
430 } catch (Exception e) {
431 String msg = "ERROR in MetaWeblogAPIHandler.getRecentPosts";
432 mLogger.error(msg,e);
433 throw new XmlRpcException(UNKNOWN_EXCEPTION, msg);
434 }
435 }
436
437
438 private Hashtable createPostStruct(WeblogEntry entry, String userid) {
439
/*
P/P * Method: Hashtable createPostStruct(WeblogEntry, String)
*
* Preconditions:
* entry != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.WeblogEntry:getCategory(...)@461 != null
* org.apache.roller.weblogger.pojos.WeblogEntry:getCreator(...)@457 != null
* org.apache.roller.weblogger.pojos.WeblogEntry:getCreator(...)@458 != null
*
* Postconditions:
* return_value == &new Hashtable(createPostStruct#2)
* new Hashtable(createPostStruct#2) num objects == 1
*
* Test Vectors:
* org.apache.roller.weblogger.pojos.WeblogEntry:getLink(...)@445: Addr_Set{null}, Inverse{null}
* org.apache.roller.weblogger.pojos.WeblogEntry:getPubTime(...)@449: Addr_Set{null}, Inverse{null}
*/
440 String permalink =
441 WebloggerRuntimeConfig.getAbsoluteContextURL() + entry.getPermaLink();
442
443 Hashtable struct = new Hashtable();
444 struct.put("title", entry.getTitle());
445 if (entry.getLink() != null) {
446 struct.put("link", Utilities.escapeHTML(entry.getLink()));
447 }
448 struct.put("description", entry.getText());
449 if (entry.getPubTime() != null) {
450 struct.put("pubDate", entry.getPubTime());
451 struct.put("dateCreated", entry.getPubTime());
452 }
453 struct.put("guid", Utilities.escapeHTML(permalink));
454 struct.put("permaLink", Utilities.escapeHTML(permalink));
455 struct.put("postid", entry.getId());
456
457 struct.put("userid", entry.getCreator().getUserName());
458 struct.put("author", entry.getCreator().getEmailAddress());
459
460 Vector catArray = new Vector();
461 catArray.addElement(entry.getCategory().getPath());
462 struct.put("categories", catArray);
463
464 return struct;
465 }
466
467
468 private Hashtable createCategoryStruct(WeblogCategory category, String userid) {
469
/*
P/P * Method: Hashtable createCategoryStruct(WeblogCategory, String)
*
* Preconditions:
* category != null
*
* Postconditions:
* return_value == &new Hashtable(createCategoryStruct#1)
* new Hashtable(createCategoryStruct#1) num objects == 1
*/
470 String contextUrl = WebloggerRuntimeConfig.getAbsoluteContextURL();
471
472 Hashtable struct = new Hashtable();
473 struct.put("description", category.getPath());
474
475 String catUrl = contextUrl+"/page/"+userid+"?catname="+category.getPath();
476 catUrl = StringUtils.replace(catUrl," ","%20");
477 struct.put("htmlUrl", catUrl);
478
+ 479 String rssUrl = contextUrl+"/rss/"+userid+"?catname="+category.getPath();
480 rssUrl = StringUtils.replace(catUrl," ","%20");
481 struct.put("rssUrl",rssUrl);
482
483 return struct;
484 }
485
486 }
SofCheck Inspector Build Version : 2.18479
| MetaWeblogAPIHandler.java |
2009-Jan-02 14:24:54 |
| MetaWeblogAPIHandler.class |
2009-Sep-04 03:12:46 |