KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > rice > rubbos > client > URLGenerator


1 package edu.rice.rubbos.client;
2
3 import java.net.URL JavaDoc;
4 import java.net.URLEncoder JavaDoc;
5
6 /**
7  * This abstract class provides the needed URLs to access all features of RUBBoS.
8  * Only the function returning script names must be defined in subclasses else
9  * every URL is generated by this class.
10  *
11  * @author <a HREF="mailto:cecchet@rice.edu">Emmanuel Cecchet</a> and <a HREF="mailto:julie.marguerite@inrialpes.fr">Julie Marguerite</a>
12  * @version 1.0
13  */

14
15 public abstract class URLGenerator
16 {
17   private static final String JavaDoc protocol = "http";
18   private String JavaDoc webSiteName;
19   private int webSitePort;
20   private String JavaDoc HTMLPath;
21   private String JavaDoc scriptPath;
22
23
24  /**
25    * Returns the name of the Search script according to the implementation (PHP, EJB or Servlets).
26    *
27    * @return Search script name
28    */

29   public abstract String JavaDoc SearchScript();
30
31
32   /**
33    * Returns the name of the Browse Categories script according to the implementation (PHP, EJB or Servlets).
34    *
35    * @return Browse Categories script name
36    */

37   public abstract String JavaDoc BrowseCategoriesScript();
38
39   /**
40    * Returns the name of the Stories of the day script according to the implementation (PHP, EJB or Servlets).
41    *
42    * @return Stories of the day script name
43    */

44   public abstract String JavaDoc StoriesOfTheDayScript();
45
46   /**
47    * Returns the name of the Older stories script according to the implementation (PHP, EJB or Servlets).
48    *
49    * @return Older stories script name
50    */

51   public abstract String JavaDoc OlderStoriesScript();
52
53   /**
54    * Returns the name of the Submit story script according to the implementation (PHP, EJB or Servlets).
55    *
56    * @return Submit story script name
57    */

58   public abstract String JavaDoc SubmitStoryScript();
59
60   /**
61    * Returns the name of the Post Comment script according to the implementation (PHP, EJB or Servlets).
62    *
63    * @return Post Comment script name
64    */

65   public abstract String JavaDoc PostCommentScript();
66
67   /**
68    * Returns the name of the Register User script according to the implementation (PHP, EJB or Servlets).
69    *
70    * @return Register User script name
71    */

72   public abstract String JavaDoc RegisterUserScript();
73
74   /**
75    * Returns the name of the Browse stories By Category script according to the implementation (PHP, EJB or Servlets).
76    *
77    * @return Browse stories by category By Category script name
78    */

79   public abstract String JavaDoc BrowseStoriesByCategoryScript();
80
81   /**
82    * Returns the name of the Store Comment script according to the implementation (PHP, EJB or Servlets).
83    *
84    * @return Store Store comment script name
85    */

86   public abstract String JavaDoc StoreCommentScript();
87
88   /**
89    * Returns the name of the Store Story script according to the implementation (PHP, EJB or Servlets).
90    *
91    * @return Store Story script name
92    */

93   public abstract String JavaDoc StoreStoryScript();
94
95   /**
96    * Returns the name of the View Story script according to the implementation (PHP, EJB or Servlets).
97    *
98    * @return View Story script name
99    */

100   public abstract String JavaDoc ViewStoryScript();
101
102   /**
103    * Returns the name of the View Comment script according to the implementation (PHP, EJB or Servlets).
104    *
105    * @return View Comment script name
106    */

107   public abstract String JavaDoc ViewCommentScript();
108
109   /**
110    * Returns the name of the Moderate Comment script according to the implementation (PHP, EJB or Servlets).
111    *
112    * @return Moderate Comment script name
113    */

114   public abstract String JavaDoc ModerateCommentScript();
115
116   /**
117    * Returns the name of the Store Moderate Log script according to the implementation (PHP, EJB or Servlets).
118    *
119    * @return Store Moderate Log script name
120    */

121   public abstract String JavaDoc StoreModerateLogScript();
122
123   /**
124    * Returns the name of the Author Tasks script according to the implementation (PHP, EJB or Servlets).
125    *
126    * @return Author Tasks script name
127    */

128   public abstract String JavaDoc AuthorTasksScript();
129
130   /**
131    * Returns the name of the Review Stories script according to the implementation (PHP, EJB or Servlets).
132    *
133    * @return Review Stories script name
134    */

135   public abstract String JavaDoc ReviewStoriesScript();
136
137   /**
138    * Returns the name of the Accept Story script according to the implementation (PHP, EJB or Servlets).
139    *
140    * @return Accept Story script name
141    */

142   public abstract String JavaDoc AcceptStoryScript();
143
144   /**
145    * Returns the name of the Accept Story script according to the implementation (PHP, EJB or Servlets).
146    *
147    * @return Accept Story script name
148    */

149   public abstract String JavaDoc RejectStoryScript();
150
151
152   /**
153    * Set the name and port of the Web site running RUBiS as well as the
154    * directories where the HTML and scripts reside.
155    *
156    * @param host Web site address
157    * @param port HTTP server port
158    * @param HTMLFilesPath path where HTML files reside
159    * @param ScriptFilesPath path to the script files
160    */

161   public URLGenerator(String JavaDoc host, int port, String JavaDoc HTMLFilesPath, String JavaDoc ScriptFilesPath)
162   {
163     webSiteName = host;
164     HTMLPath = HTMLFilesPath;
165     scriptPath = ScriptFilesPath;
166     webSitePort = port;
167   }
168
169   /** Set the web site name.
170    * For example:
171    * <pre>
172    * URLGenerator urlGen = new URLGenerator();
173    * urlGen.setWebSiteName("www.testbed.cs.rice.edu");
174    * </pre>
175    *
176    * @param host location
177    */

178   public void setWebSiteName(String JavaDoc host)
179   {
180     webSiteName = host;
181   }
182
183   /** Set the location where the HTML files reside on the web site.
184    * For example:
185    * <pre>
186    * URLGenerator urlGen = new URLGenerator();
187    * urlGen.setHTMLPath("/EJB_HTML");
188    * </pre>
189    *
190    * @param p HTML files path
191    */

192   public void setHTMLPath(String JavaDoc p)
193   {
194     HTMLPath = p;
195   }
196
197
198   /** Set the location where the script files reside on the web site.
199    * For example:
200    * <pre>
201    * URLGenerator urlGen = new URLGenerator();
202    * urlGen.setScriptPath("/servlet");
203    * </pre>
204    *
205    * @param p HTML files path
206    */

207   public void setScriptPath(String JavaDoc p)
208   {
209     scriptPath = p;
210   }
211
212
213   /**
214    * Set the value of http server port.
215    *
216    * @param p http server port
217    */

218   public void setWebSitePort(int p)
219   {
220     webSitePort = p;
221   }
222
223
224   /**
225    * Return the string representing a float number in a format understandable by the database.
226    * This function needs to be fixed since it still does not work with large number.
227    *
228    * @param f the float value to convert
229    * @return a string representing the float conforming to database representation.
230    */

231   protected String JavaDoc convertFloatToStringDatabaseFormat(float f)
232   {
233     String JavaDoc result = Float.toString(f);
234     int E = result.indexOf('E');
235     if (E != -1)
236     /* We have something like 1.2345E6 but the database needs 1.2345E+6
237        So, we need to add the + */

238       result = result.substring(0,E+1)+"+"+result.substring(E+1);
239     return result;
240   }
241
242   // ===========================================================
243
// ==================== URL Generation =======================
244
// ===========================================================
245

246
247   /** URL to the page corresponding to the file.
248    *
249    * @param filename file name
250    * @return the URL corresponding to the file
251    */

252   public URL JavaDoc genericHTMLFile(String JavaDoc filename)
253   {
254     try
255     {
256       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, filename);
257       return url;
258     }
259     catch (java.net.MalformedURLException JavaDoc e)
260     {
261       System.out.println("Error while generating the URL corresponding to the file: "+e.getMessage());
262       return null;
263     }
264   }
265
266   // =====================================================
267
// ==================== Home page ======================
268
// =====================================================
269

270   /** URL to the home page of the web site.
271    * Actually, it displays Stories of the Day.
272    *
273    * @return home page URL
274    */

275   public URL JavaDoc homePage()
276   {
277     try
278     {
279       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+StoriesOfTheDayScript());
280       return url;
281     }
282     catch (java.net.MalformedURLException JavaDoc e)
283     {
284       System.out.println("Error while generating home page URL: "+e.getMessage());
285       return null;
286     }
287   }
288
289
290   // =====================================================
291
// ==================== Register =======================
292
// =====================================================
293

294   /** URL to the register user page of the web site.
295    *
296    * @return register user page URL
297    */

298   public URL JavaDoc register()
299   {
300     try
301     {
302       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, HTMLPath+"/register.html");
303       return url;
304     }
305     catch (java.net.MalformedURLException JavaDoc e)
306     {
307       System.out.println("Error while generating register page URL: "+e.getMessage());
308       return null;
309     }
310   }
311
312   /**
313    * Register a new user in the database. You must provide all
314    * information that are requested by the web page.
315    *
316    * @param firstname user's first name
317    * @param lastname user's last name
318    * @param nickname user's nick name (login name)
319    * @param email user's email address
320    * @param password user's password
321    * @return URL to use to register a new user
322    */

323   public URL JavaDoc registerUser(String JavaDoc firstname, String JavaDoc lastname, String JavaDoc nickname,
324                          String JavaDoc email, String JavaDoc password)
325   {
326     try
327     {
328       firstname = URLEncoder.encode(firstname);
329       lastname = URLEncoder.encode(lastname);
330       nickname = URLEncoder.encode(nickname);
331       email = URLEncoder.encode(email);
332       password = URLEncoder.encode(password);
333       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+RegisterUserScript()+"?firstname="+firstname+"&lastname="+
334       lastname+"&nickname="+nickname+"&email="+email+"&password="+password);
335       return url;
336     }
337     catch (java.net.MalformedURLException JavaDoc e)
338     {
339       System.out.println("Error while generating register user page URL: "+e.getMessage());
340       return null;
341     }
342   }
343
344
345   // =====================================================
346
// ==================== Browsing =======================
347
// =====================================================
348

349   /** URL to the browse page of the web site.
350    *
351    * @return browse page URL
352    */

353   public URL JavaDoc browse()
354   {
355     try
356     {
357       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, HTMLPath+"/browse.html");
358       return url;
359     }
360     catch (java.net.MalformedURLException JavaDoc e)
361     {
362       System.out.println("Error while generating browse page URL: "+e.getMessage());
363       return null;
364     }
365   }
366
367
368   /** Access the Browse Categories page of RUBBoS that lists all
369    * available categories. The user can then select a category
370    * to view all items in that category.
371    *
372    * @return Browse categories script URL
373    */

374   public URL JavaDoc browseCategories()
375   {
376     try
377     {
378       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+BrowseCategoriesScript());
379       return url;
380     }
381     catch (java.net.MalformedURLException JavaDoc e)
382     {
383       System.out.println("Error while generating Browse Categories script URL: "+e.getMessage());
384       return null;
385     }
386   }
387
388   /** Access the Stories of the day page of RUBBoS that lists
389    * the 10 most recent stories.
390    *
391    * @return Stories of the day script URL
392    */

393   public URL JavaDoc StoriesOfTheDay()
394   {
395     try
396     {
397       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+StoriesOfTheDayScript());
398       return url;
399     }
400     catch (java.net.MalformedURLException JavaDoc e)
401     {
402       System.out.println("Error while generating Stories of the day script URL: "+e.getMessage());
403       return null;
404     }
405   }
406
407   /** Access the Older Stories page of RUBBoS that lists
408    * the stories of a specific day.
409    *
410    * @param day day to look for
411    * @param month month to look for
412    * @param year year to look for
413    * @param page page to view (0=first page)
414    * @param nbOfStories number of stories to display per page
415    *
416    * @return Older Stories script URL
417    */

418   public URL JavaDoc OlderStories(int day, int month, int year, int page, int nbOfStories)
419   {
420     try
421     {
422       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+OlderStoriesScript()+
423                         "?day="+day+"&month="+month+"&year="+year+"&page="+page+"&nbOfStories="+nbOfStories);
424       return url;
425     }
426     catch (java.net.MalformedURLException JavaDoc e)
427     {
428       System.out.println("Error while generating Older stories script URL: "+e.getMessage());
429       return null;
430     }
431   }
432
433   /**
434    * URL to the 'browse all stories in a category' script. You must
435    * provide both the category id and category name.
436    *
437    * @param categoryId category id
438    * @param categoryName category name
439    * @param page page to view (0=first page)
440    * @param nbOfStories number of stories to display per page
441    *
442    * @return 'browse all stories in a category' script URL
443    */

444   public URL JavaDoc browseStoriesByCategory(int categoryId, String JavaDoc categoryName, int page, int nbOfStories)
445   {
446     try
447     {
448       categoryName = URLEncoder.encode(categoryName);
449       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+BrowseStoriesByCategoryScript()+
450                         "?category="+categoryId+"&categoryName="+categoryName+"&page="+page+"&nbOfStories="+nbOfStories);
451       return url;
452     }
453     catch (java.net.MalformedURLException JavaDoc e)
454     {
455       System.out.println("Error while generating 'browse all stories in a category' script URL: "+e.getMessage());
456       return null;
457     }
458   }
459
460   /** URL to the 'View Story' script. You must provide the story id.
461    *
462    * @param storyId story identifier
463    *
464    * @return 'View Story' script URL
465    */

466   public URL JavaDoc viewStory(int storyId)
467   {
468     try
469     {
470       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+ViewStoryScript()+"?storyId="+storyId);
471       return url;
472     }
473     catch (java.net.MalformedURLException JavaDoc e)
474     {
475       System.out.println("Error while generating 'View Story' script URL: "+e.getMessage());
476       return null;
477     }
478   }
479
480
481  /**
482    * URL to the 'Search' script.
483    *
484    * @param searchType Type of the research : search on 0=stories, 1=comments, 2=users
485    * @param keyword keyword for the search
486    * @param page page to view (0=first page)
487    * @param nbOfStories number of stories or comments to display per page
488    *
489    * @return 'Search' script URL
490    */

491   public URL JavaDoc search(String JavaDoc keyword, String JavaDoc searchType, int page, int nbOfStories)
492   {
493     try
494     {
495       URL JavaDoc url;
496       if (keyword == null)
497         url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+SearchScript());
498       else
499         url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+SearchScript()+
500                       "?type="+URLEncoder.encode(searchType)+"&search="+URLEncoder.encode(keyword)+"&page="+page+"&nbOfStories="+nbOfStories);
501       return url;
502     }
503     catch (java.net.MalformedURLException JavaDoc e)
504     {
505       System.out.println("Error while generating 'Search' script URL: "+e.getMessage());
506       return null;
507     }
508   }
509
510   // =====================================================
511
// ==================== Comments =======================
512
// =====================================================
513

514   /** URL to the 'Post Comment on a story or another comment' script.
515    * This is the page the user can access when it has been successfully authenticated.
516    *
517    * @param storyId story identifier
518    * @param parent parent comment identifier
519    * @param comment_table the comment_table to use (comments or old_comments)
520    *
521    * @return 'Post Comment' script URL
522    */

523   public URL JavaDoc postComment(int storyId, int parent, String JavaDoc comment_table)
524   {
525     try
526     {
527       comment_table = URLEncoder.encode(comment_table);
528       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+PostCommentScript()+"?storyId="+storyId+"&parent="+parent+"&comment_table="+comment_table);
529       return url;
530     }
531     catch (java.net.MalformedURLException JavaDoc e)
532     {
533       System.out.println("Error while generating 'Post Comment' script URL: "+e.getMessage());
534       return null;
535     }
536   }
537
538
539   /** URL to the 'StoreComment' script. This action really stores a new comment in the database.
540    *
541    * @param name user's nickname
542    * @param pwd user's password
543    * @param storyId story identifier
544    * @param parent parent comment identifier
545    * @param subject the subject of the comment
546    * @param body the comment text itself
547    * @param comment_table the comment_table to use (comments or old_comments)
548    *
549    * @return 'Store Comment' script URL
550    */

551   public URL JavaDoc storeComment(String JavaDoc name, String JavaDoc pwd, int storyId, int parent, String JavaDoc subject, String JavaDoc body, String JavaDoc comment_table)
552   {
553     try
554     {
555       name = URLEncoder.encode(name);
556       pwd = URLEncoder.encode(pwd);
557       subject = URLEncoder.encode(subject);
558       body = URLEncoder.encode(body);
559       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+StoreCommentScript()+"?comment_table="+comment_table
560                         +"&nickname="+name+"&password="+pwd+"&storyId="+storyId+"&parent="+parent+"&subject="+subject+"&body="+body);
561       return url;
562     }
563     catch (java.net.MalformedURLException JavaDoc e)
564     {
565       System.out.println("Error while generating StoreComment script URL: "+e.getMessage());
566       return null;
567     }
568   }
569
570
571   /**
572    * URL to the 'View Comment' script. You must provide the comment id.
573    *
574    * @param commentId comment identifier
575    * @param filter filter value
576    * @param display display value
577    * @param storyId story identifier
578    * @param comment_table the comment_table to use (comments or old_comments)
579    *
580    * @return 'View Comment' script URL
581    */

582   public URL JavaDoc viewComment(int commentId, int filter, int display, int storyId, String JavaDoc comment_table)
583   {
584     try
585     {
586       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+ViewCommentScript()+"?commentId="+commentId+"&filter="+filter+
587                         "&display="+display+"&storyId="+storyId+"&comment_table="+comment_table);
588       return url;
589     }
590     catch (java.net.MalformedURLException JavaDoc e)
591     {
592       System.out.println("Error while generating 'View comment' script URL: "+e.getMessage());
593       return null;
594     }
595   }
596
597
598   /**
599    * URL to the 'Moderate Comment' script. You must provide the comment id.
600    *
601    * @param commentId comment identifier
602    * @param comment_table the comment_table to use (comments or old_comments)
603    *
604    * @return 'Moderate Comment' script URL
605    */

606   public URL JavaDoc moderateComment(int commentId, String JavaDoc comment_table)
607   {
608     try
609     {
610       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+ModerateCommentScript()+
611                         "?commentId="+commentId+"&comment_table="+comment_table);
612       return url;
613     }
614     catch (java.net.MalformedURLException JavaDoc e)
615     {
616       System.out.println("Error while generating 'View comment' script URL: "+e.getMessage());
617       return null;
618     }
619   }
620
621
622   /** URL to the 'Store Moderate Log' script. This action really stores a new comment in the database.
623    *
624    * @param name user's nickname
625    * @param pwd user's password
626    * @param commentId comment identifier
627    * @param rating comment's rating
628    * @param comment_table the comment_table to use (comments or old_comments)
629    *
630    * @return 'Store Moderate Log' script URL
631    */

632   public URL JavaDoc storeModerateLog(String JavaDoc name, String JavaDoc pwd, int commentId, int rating, String JavaDoc comment_table)
633   {
634     try
635     {
636       name = URLEncoder.encode(name);
637       pwd = URLEncoder.encode(pwd);
638       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+StoreModerateLogScript()+"?comment_table="+comment_table
639                         +"&nickname="+name+"&password="+pwd+"&commentId="+commentId+"&rating="+rating);
640       return url;
641     }
642     catch (java.net.MalformedURLException JavaDoc e)
643     {
644       System.out.println("Error while generating StoreComment script URL: "+e.getMessage());
645       return null;
646     }
647   }
648
649
650   // ====================================================
651
// ==================== Submit story ==================
652
// ====================================================
653

654  /** URL to the Submit Story script.
655    *
656    * @return 'Submit Story' script URL
657    */

658   public URL JavaDoc submitStory()
659   {
660     try
661     {
662       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+SubmitStoryScript());
663       return url;
664     }
665     catch (java.net.MalformedURLException JavaDoc e)
666     {
667       System.out.println("Error while generating 'Submit Story' script URL: "+e.getMessage());
668       return null;
669     }
670   }
671  
672
673   /** URL to the 'Store story' script. This action really stores a new story in the database.
674    *
675    * @param name user's nickname
676    * @param pwd user's password
677    * @param title story title
678    * @param body the story itself
679    * @param categoryId category identifier
680    *
681    * @return 'Store story' script URL
682    */

683   public URL JavaDoc storeStory(String JavaDoc name, String JavaDoc pwd, String JavaDoc title, String JavaDoc body, int categoryId)
684   {
685     try
686     {
687       name = URLEncoder.encode(name);
688       pwd = URLEncoder.encode(pwd);
689       title = URLEncoder.encode(title);
690       body = URLEncoder.encode(body);
691       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+StoreStoryScript()+"?nickname="+name+"&password="+pwd+"&category="+categoryId+"&title="+title+"&body="+body);
692       return url;
693     }
694     catch (java.net.MalformedURLException JavaDoc e)
695     {
696       System.out.println("Error while generating 'Store Story' script URL: "+e.getMessage());
697       return null;
698     }
699   }
700
701
702   // ===============================================
703
// ==================== Authors ==================
704
// ===============================================
705

706   /** URL to the Submit Story on a story or another comment' script.
707    *
708    * @return 'Author login' URL
709    */

710   public URL JavaDoc authorLogin()
711   {
712     try
713     {
714       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, HTMLPath+"/author.html");
715       return url;
716     }
717     catch (java.net.MalformedURLException JavaDoc e)
718     {
719       System.out.println("Error while generating 'Author login' URL: "+e.getMessage());
720       return null;
721     }
722   }
723  
724
725   /** URL to the 'Author tasks' script.
726    *
727    * @param name user's nickname
728    * @param pwd user's password
729    *
730    * @return 'Author tasks' script URL
731    */

732   public URL JavaDoc authorTasks(String JavaDoc name, String JavaDoc pwd)
733   {
734     try
735     {
736       name = URLEncoder.encode(name);
737       pwd = URLEncoder.encode(pwd);
738       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+AuthorTasksScript()+"?nickname="+name+"&password="+pwd);
739       return url;
740     }
741     catch (java.net.MalformedURLException JavaDoc e)
742     {
743       System.out.println("Error while generating 'Author tasks' script URL: "+e.getMessage());
744       return null;
745     }
746   }
747
748   /** URL to the 'Review Stories' script.
749    *
750    * @return 'Review Stories' script URL
751    */

752   public URL JavaDoc reviewStories()
753   {
754     try
755     {
756       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+ReviewStoriesScript());
757       return url;
758     }
759     catch (java.net.MalformedURLException JavaDoc e)
760     {
761       System.out.println("Error while generating 'Review Stories' script URL: "+e.getMessage());
762       return null;
763     }
764   }
765
766   /** URL to the 'Accept Story' script. You must provide the story id.
767    *
768    * @param storyId story identifier
769    *
770    * @return 'Accept Story' script URL
771    */

772   public URL JavaDoc acceptStory(int storyId)
773   {
774     try
775     {
776       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+AcceptStoryScript()+"?storyId="+storyId);
777       return url;
778     }
779     catch (java.net.MalformedURLException JavaDoc e)
780     {
781       System.out.println("Error while generating 'Accept Story' script URL: "+e.getMessage());
782       return null;
783     }
784   }
785
786
787   /** URL to the 'Reject Story' script. You must provide the story id.
788    *
789    * @param storyId story identifier
790    *
791    * @return 'Reject Story' script URL
792    */

793   public URL JavaDoc rejectStory(int storyId)
794   {
795     try
796     {
797       URL JavaDoc url = new URL JavaDoc(protocol, webSiteName, webSitePort, scriptPath+"/"+RejectStoryScript()+"?storyId="+storyId);
798       return url;
799     }
800     catch (java.net.MalformedURLException JavaDoc e)
801     {
802       System.out.println("Error while generating 'Reject Story' script URL: "+e.getMessage());
803       return null;
804     }
805   }
806
807 }
808
Popular Tags