<%@ page import="java.util.Iterator,com.coolservlets.forum.*" %> <% //JSP to print out the names of all the threads in a forum. //Get an anonymous authorization object. Authorization auth = AuthorizationFactory.getAnonymousAuthorization(); ForumFactory factory = ForumFactory.getInstance(auth); //Loading a forum object throws an Unauthorized exception if the //the permissions set on the forum don@#t correspond to your aclearcase/" target="_blank" >ccess level. try { //Load the forum named myForum Forum forum = factory.getForum("myForum"); //Get an iterator for all the threads in myForum Iterator threads = forum.threads(); while (threads.hasNext() ) { ForumThread thread = (ForumThread)threads.next(); %> <%= thread.getName() %> <% } } catch (UnauthorizedException ue) { System.err.println("You do not have permission to read this forum."); } %> |
| public static Authorization getLJJiveAdminAuthorization(){ if (m_adminAuth != null) { return m_adminAuth; } else { try { m_adminAuth = AuthorizationFactory.getAuthorization( ADMIN_ID, ADMIN_PWD );} catch( UnauthorizedException ue ) { System.out.println("Error in getLJJiveAdminAuthorization: " + ue.toString()); } } return m_adminAuth;} |
public User createForumUser(String name, String username, String password, String email) { ProfileManager profileManager = null; ForumFactory forumFactory = null; User newUser = null; forumFactory = ForumFactory.getInstance(ForumHelper.getLJJiveAdminAuthorization()); try { if (forumFactory != null) { profileManager = forumFactory.getProfileManager(); newUser = profileManager.createUser(username,password,email); newUser.setName( name ); newUser.setEmailVisible(true); newUser.setNameVisible(true); } } catch( UserAlreadyExistsException uaee ) { System.out.println("Error in createUser: " + uaee.toString()); System.out.println("User is: " + username); } catch( UnauthorizedException ue ) { System.out.println("Error in createUser: " + ue.toString()); } return newUser; } |
public User getUser(String userName, String password) { ProfileManager profileManager = null; ForumFactory forumFactory = null; User user = null; Authorization userAuth = getUserAuthorization(userName, password); if (userAuth == null) return null; forumFactory = ForumFactory.getInstance(ForumHelper.getLJJiveAdminAuthorization()); try { if (forumFactory != null) { profileManager = forumFactory.getProfileManager(); user = profileManager.getUser( userAuth.getUserID() ); } } catch( UserNotFoundException unfe ) { System.out.println("Error in getUser: " + unfe.toString()); } return user; } |
ForumHelper forumHelper = new ForumHelper(); User user = forumHelper.getUser(userBean.getScreenName(), userBean.getPassword()); if (user != null) { session.putValue(LockerjockConstants.SESSION_JIVE_USER, user); } |
<% User jiveUser = (User)session.getValue(LockerjockConstants.LOCKERJOCK_JIVE_USER); UserBean userBean = (UserBean)session.getValue(LockerjockConstants.LOCKERJOCK_USER_BEAN); if (jiveUser != null && userBean != null) { // do forum stuff, yadayadayada } %> |
<% String pForumID = request.getParameter("forum"); // get the forumID, create the forum object int forumID = ((pForumID!=null&&!pForumID.equals(""))?(Integer.parseInt(pForumID)):-1); ForumFactory forumFactory = ForumHelper.getForumFactory(ForumHelper.getLJJiveAdminAuthorization()); Forum forum = null; String forumName = null; try { if (forumFactory != null) forum = forumFactory.getForum(forumID); } catch( UnauthorizedException ue ) { //default Jive forum JSPs redirect to an error page if //the forum factory doesn@#t have permission to get this forum } catch( ForumNotFoundException fnfe ) { } if (forum != null) forumName = forum.getName(); %> |
public Forum createForum(String name, String description) { ForumFactory forumFactory = null; Forum newForum = null; try { if( description == null ) description = ""; forumFactory = ForumFactory.getInstance(ForumHelper.getLJJiveAdminAuthorization()); if (forumFactory != null) newForum = forumFactory.createForum( name, description ); } catch( UnauthorizedException ue ) { System.out.println("Error in createForum: " + ue.toString()); } catch( ForumAlreadyExistsException fae ) { System.out.println("Error in createForum: " + fae.toString()); } return newForum; } |