发帖    主题    评论    推荐    标签    作者    订阅    查搜    注册   登陆   关注
 
面向对象 设计模式 领域驱动设计 企业架构 框架 开发教程 微服务 大数据 扩展性 并发编程 事件驱动 分布式 SOA

???????

2003-01-18 17:45
赞助商链接

<%@ page contentType="text/html;charset=ISO8859_1" %>
<%@ page import="java.util.*,
com.jivesoftware.forum.*,
com.jivesoftware.forum.util.*" %>

<%@ include file="global.jsp" %>

<%! // Global variables, methods, etc

// Permission presets
static final int USE_GLOBAL_PERMS = 1;
static final int ALL_ACCESS = 2;
static final int USERS_ONLY = 3;
static final int USERS_AND_ANON_READ = 4;

static final int DEFAULT_PERM_PRESET = USE_GLOBAL_PERMS;

static final int[] PERM_PRESETS = {
USE_GLOBAL_PERMS,
USERS_ONLY,
USERS_AND_ANON_READ,
ALL_ACCESS
};

static final String[][] PERM_PRESET_INFO = {
{"使用全局权限","对此论坛使用全局权限设置。"},
{"注册用户","只有注册用户可以阅读和发表消息。"},
{"注册用户,来客可读","来客只能阅读,注册用户可以阅读和发布消息。"},
{"无限制","任何人都可以阅读和发布消息。"}
};
%>

<% // Get parameters
String submitButton = ParamUtils.getParameter(request,"submitButton");
boolean doCreate = ParamUtils.getBooleanParameter(request,"doCreate");
String name = ParamUtils.getParameter(request,"name");
String description = ParamUtils.getParameter(request,"description");
int permPreset = ParamUtils.getIntParameter(request,"permPreset",DEFAULT_PERM_PRESET);
// Remove the forum in the session (if we come to this page, the sidebar
// shouldn't show the specific forum options).
session.removeAttribute("admin.sidebar.forums.currentForum");

// Cancel, if requested
if ("取消".equals(submitButton)) {
response.sendRedirect("forums.jsp");
return;
}

// Check for errors
boolean errors = false;
if (doCreate) {
if (name == null) {
errors = true;
}
}
if (doCreate && !errors)
{
Forum forum = forumFactory.createForum(name, description);
PermissionsManager permManager = forum.getPermissionsManager();

switch (permPreset)
{
case USE_GLOBAL_PERMS:break;
case USERS_ONLY:
permManager.addRegisteredUserPermission(ForumPermissions.READ);
permManager.addRegisteredUserPermission(ForumPermissions.CREATE_THREAD);
permManager.addRegisteredUserPermission(ForumPermissions.CREATE_MESSAGE);
break;
case USERS_AND_ANON_READ:
permManager.addRegisteredUserPermission(ForumPermissions.READ);
permManager.addRegisteredUserPermission(ForumPermissions.CREATE_THREAD);
permManager.addRegisteredUserPermission(ForumPermissions.CREATE_MESSAGE);
permManager.addAnonymousUserPermission(ForumPermissions.READ);
break;
case ALL_ACCESS:
permManager.addRegisteredUserPermission(ForumPermissions.READ);
permManager.addRegisteredUserPermission(ForumPermissions.CREATE_THREAD);
permManager.addRegisteredUserPermission(ForumPermissions.CREATE_MESSAGE);
permManager.addAnonymousUserPermission(ForumPermissions.READ);
permManager.addAnonymousUserPermission(ForumPermissions.CREATE_THREAD);
permManager.addAnonymousUserPermission(ForumPermissions.CREATE_MESSAGE);
break;
default:
}

// redirect back to the forums page
response.sendRedirect("forums.jsp");
return;
}
%>

<% // special onload command to load the sidebar
onload = " onload=\"parent.frames['sidebar'].location.href='sidebar.jsp?sidebar=forum';\"";
%>
<%@ include file="header.jsp" %>

<p>

<% // Title of this page and breadcrumbs
String title = "创建新论坛";
String[][] breadcrumbs = {
{"主页面", "main.jsp"},
{"论坛", "forums.jsp"},
{title, "createForum.jsp"}
};
%>
<%@ include file="title.jsp" %>

<font size="-1">
注意:这将创建一个没有权限的论坛。创建完成后,你将被带到论坛权限设置页面。
</font>

<p>

<% // error messages
if(errors) {
%>
<font color="<%= errorColor %>" size="-1">
论坛创建错误。请确认你输入了论坛名!
</font>
<p>
<% } %>

<form action="createForum.jsp" method="post" name="createForm">
<input type="hidden" name="doCreate" value="true">

<font size="-1"><b>论坛名</b></font>
<ul>
<input type="text" name="name" size="40" maxlength="100" value="<%= (name!=null)?name:"" %>">
</ul>

<font size="-1"><b>论坛描述</b> (可选)</font>
<ul>
<textarea name="description" cols="40" rows="5" wrap="virtual"><%= (description!=null)?description:"" %></textarea>
</ul>

<font size="-1"><b>论坛权限先期设置</b></font>
<ul>
<font size="-1">
要获得更好的权限控制(包括用户组设置),请查看权限设置页面。
<p>
</font>
<table cellpadding="3" cellspacing="0" border="0">
<% for (int i=0; i<PERM_PRESETS.length; i++) {
String checked = "";
if (PERM_PRESETS == permPreset) {
checked = " checked";
}
%>
<tr>
<td valign="top"><input type="radio" name="permPreset" value="<%= PERM_PRESETS %>" id="rb<%= i %>"<%= checked %>></td>
<td><font size="-1"><label for="rb<%= i %>">
<b><%= PERM_PRESET_INFO[0] %></b>
--
<%= PERM_PRESET_INFO[1] %>
</label></font>
</td>
</tr>
<% } %>
</table>
</ul>

<input type="submit" name="submitButton" value="创建论坛">
<input type="submit" name="submitButton" value="取消">
</form>

<script language="JavaScript" type="text/javascript">
<!--
document.createForm.name.focus();
//-->
</script>

<%@ include file="footer.jsp" %>



*************ForumFactory.java***************

package com.jivesoftware.forum;

import java.lang.reflect.*;
import java.util.*;

public abstract class ForumFactory
{
private static Object initLock = new Object();
private static String className = "com.jivesoftware.forum.database.DbForumFactory";
private static ForumFactory factory = null;

public static ForumFactory getInstance(Authorization authorization)
{

if (authorization == null)
{
return null;
}
if (factory == null)
{
synchronized(initLock)
{
if (factory == null)
{
String classNameProp =
JiveGlobals.getJiveProperty("ForumFactory.className");
if (classNameProp != null)
{
className = classNameProp;
}
try
{
Class c = Class.forName(className);
factory = (ForumFactory)c.newInstance();
}
catch (Exception e)
{
System.err.println("Failed to load ForumFactory class "
+ className + ". Jive cannot function normally.");
e.printStackTrace();
return null;
}
}
}
}
//Now, create a forum factory proxy.
return new ForumFactoryProxy(authorization, factory,
factory.getPermissions(authorization));
}


public abstract Forum createForum(String name, String description)
throws UnauthorizedException, ForumAlreadyExistsException;

public abstract ForumThread createThread(ForumMessage rootMessage) throws
UnauthorizedException;


public abstract ForumMessage createMessage();


public abstract ForumMessage createMessage(User user)
throws UnauthorizedException;


public abstract Forum getForum(long forumID)
throws ForumNotFoundException, UnauthorizedException;

public abstract Forum getForum(String name)
throws ForumNotFoundException, UnauthorizedException;


public abstract int getForumCount();


public abstract Iterator forums();


public abstract Query createQuery();


public abstract Query createQuery(Forum [] forums);


public abstract Iterator popularForums();

public abstract Iterator popularThreads();

public abstract void deleteForum(Forum forum)
throws UnauthorizedException;

public abstract void mergeForums(Forum forum1, Forum forum2)
throws UnauthorizedException;

public abstract UserManager getUserManager();

public abstract GroupManager getGroupManager();

public abstract SearchManager getSearchManager()
throws UnauthorizedException;


public abstract FilterManager getFilterManager();


public abstract WatchManager getWatchManager();

public abstract RewardManager getRewardManager();

public abstract PermissionsManager getPermissionsManager()
throws UnauthorizedException;

public abstract ForumMessageFilter [] getAvailableFilters()
throws UnauthorizedException;

public abstract void addFilterClass(String className)
throws UnauthorizedException, ClassNotFoundException,
IllegalArgumentException;

public abstract ForumPermissions getPermissions(Authorization authorization);


public abstract boolean hasPermission(int type);
}


***************接口Form****************

package com.jivesoftware.forum;

import java.util.Date;
import java.util.Iterator;
import java.util.Enumeration;

public interface Forum
{

public long getID();

public String getName();

public void setName(String name) throws UnauthorizedException,ForumAlreadyExistsException;

public String getDescription();

public void setDescription(String description) throws UnauthorizedException;

public Date getCreationDate();

public void setCreationDate(Date creationDate) throws UnauthorizedException;

public Date getModifiedDate();

public void setModifiedDate(Date modifiedDate) throws UnauthorizedException;

public int getModerationDefaultThreadValue();

public void setModerationDefaultThreadValue(int value) throws UnauthorizedException;

public int getModerationDefaultMessageValue();

public void setModerationDefaultMessageValue(int value) throws UnauthorizedException;

public int getModerationMinThreadValue();

public void setModerationMinThreadValue(int value) throws UnauthorizedException;

public int getModerationMinMessageValue();

public void setModerationMinMessageValue(int value) throws UnauthorizedException;



public String getProperty(String name);


public void setProperty(String name, String value) throws UnauthorizedException;


public void deleteProperty(String name) throws UnauthorizedException;


public Iterator propertyNames();


public ForumThread getThread(long threadID) throws ForumThreadNotFoundException;


public void addThread(ForumThread thread) throws UnauthorizedException;


public void deleteThread(ForumThread thread) throws UnauthorizedException;


public void moveThread(ForumThread thread, Forum newForum)throws UnauthorizedException, IllegalArgumentException;


public ForumThreadIterator threads();


public ForumThreadIterator threads(ResultFilter resultFilter);


public Iterator popularThreads();


public Iterator messages();


public Iterator messages(ResultFilter resultFilter);

public int getThreadCount();


public int getThreadCount(ResultFilter resultFilter);


public int getMessageCount();


public int getMessageCount(ResultFilter resultFilter);


public Query createQuery();


public FilterManager getFilterManager();


public PermissionsManager getPermissionsManager()throws UnauthorizedException;


public abstract ForumPermissions getPermissions(Authorization authorization);


public boolean hasPermission(int type);
}

请问在在*.JSP中
Forum forum = forumFactory.createForum(name, description);
PermissionsManager permManager = forum.getPermissionsManager();
是如何把参数(name,description)传递具体的又是那个*.class文件接受这个参数????

赞助商链接

赞助商链接

返回顶部

移动版 关于本站 使用帮助 联系管理员 最佳分辨率1366x768
OpenSource JIVEJDON Powered by JdonFramework Code © 2002-20 jdon.com