KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > freeforums > jspbeans > ForumController


1 /*
2  * ForumController.java
3  *
4  * JavaBean to allow the JSP pages to perform the right
5  * user functions.
6  *
7  * @author: Devraj Mukherjee
8  *
9  */

10
11 package freeforums.jspbeans;
12
13 import javax.naming.*;
14 import java.util.Hashtable JavaDoc;
15 import javax.rmi.PortableRemoteObject JavaDoc;
16 import java.util.Properties JavaDoc;
17 import java.io.FileInputStream JavaDoc;
18 import java.util.Properties JavaDoc;
19
20 import freeforums.forum.ForumManager;
21 import freeforums.forum.ForumManagerHome;
22 import freeforums.forum.Forum;
23 import freeforums.forum.ForumHome;
24
25 import org.jdom.*;
26
27
28 public class ForumController extends Object JavaDoc {
29
30     /**
31      Empty Constructor expected to do nothing
32      **/

33
34     public ForumController() { }
35
36     /**
37      Forum Listing for User
38      **/

39
40     public Document getForumListingForUser(Document UserDetails) {
41
42         try {
43             //Get the home interface for the user management bean
44
ForumManagerHome home = (ForumManagerHome) new InitialContext().lookup("ForumManagerBean");
45             // Create the manager object
46
ForumManager manager = home.create();
47             return manager.findForumsForUser(UserDetails);
48
49         }
50         catch(Exception JavaDoc e) {
51             // do nothing much
52
System.err.println("Exception occured \n" + e);
53             return (new Document(new Element("Response").addContent("Failed")));
54         }
55
56      } // End Method getForumListingForUser
57

58     /**
59      Complete Forum Listing
60      **/

61
62      public Document getCompleteForumListing() {
63
64         try {
65             //Get the home interface for the user management bean
66
ForumManagerHome home = (ForumManagerHome) new InitialContext().lookup("ForumManagerBean");
67             // Create the manager object
68
ForumManager manager = home.create();
69             return manager.findAll();
70
71         }
72         catch(Exception JavaDoc e) {
73             // do nothing much
74
System.err.println("Exception occured \n" + e);
75             return (new Document(new Element("Response").addContent("Failed")));
76         }
77
78      } // End Method getCompleteForumListing
79

80      public Document addForum(Document ForumInformation) {
81
82         try {
83             //Get the home interface for the user management bean
84
ForumManagerHome home = (ForumManagerHome) new InitialContext().lookup("ForumManagerBean");
85             // Create the manager object
86
ForumManager manager = home.create();
87             return manager.addForum(ForumInformation);
88
89         }
90         catch(Exception JavaDoc e) {
91             // do nothing much
92
System.err.println("Exception occured \n" + e);
93             return (new Document(new Element("Response").addContent("Failed")));
94         }
95
96      } // End Method Add Forum
97

98      public Document getForumListForUser(Document ForumInformation) {
99
100         try {
101             //Get the home interface for the user management bean
102
ForumManagerHome home = (ForumManagerHome) new InitialContext().lookup("ForumManagerBean");
103             // Create the manager object
104
ForumManager manager = home.create();
105             return manager.findForumsForUser(ForumInformation);
106
107         }
108         catch(Exception JavaDoc e) {
109             // do nothing much
110
System.err.println("Exception occured \n" + e);
111             return (new Document(new Element("Response").addContent("Failed")));
112         }
113
114      } // End Method getForumListForUser
115

116      public Document isUserAllowed(Document ForumUserInfo) {
117
118         try {
119             //Get the home interface for the user management bean
120
ForumManagerHome home = (ForumManagerHome) new InitialContext().lookup("ForumManagerBean");
121             // Create the manager object
122
ForumManager manager = home.create();
123             return manager.isUserAllowed(ForumUserInfo);
124
125         }
126         catch(Exception JavaDoc e) {
127             // do nothing much
128
System.err.println("Exception occured \n" + e);
129             return (new Document(new Element("Response").addContent("Failed")));
130         }
131
132      } // End Method
133

134 } // End Class file
Popular Tags