📄 _groupperms__jsp.java
字号:
/*
* JSP generated by Resin 2.1.2 (built Tue Jun 11 08:26:56 PDT 2002)
*/
package _admin._forum;
import javax.servlet.*;
import javax.servlet.jsp.*;
import javax.servlet.http.*;
import java.util.*;
import java.net.URLEncoder;
import com.coolservlets.forum.*;
import com.coolservlets.forum.util.*;
import com.coolservlets.forum.util.admin.*;
public class _groupperms__jsp extends com.caucho.jsp.JavaPage{
private boolean _caucho_isDead;
////////////////////////
// global page variables
private final String ADD = " Add ";
private final String REMOVE = "Remove";
///////////////////
// global methods
private String getParameterMode( String paramVal ) {
if( paramVal == null ) {
return "";
}
if( paramVal.equals(ADD) ) { return "add"; }
else if( paramVal.equals(REMOVE) ) { return "remove"; }
else {
return "";
}
}
private int[] getIntListboxParams( String[] paramVal ) {
if( paramVal == null ) {
return new int[0];
}
int[] params = new int[paramVal.length];
for (int i=0;i<paramVal.length;i++)
{
try {
params[i] = Integer.parseInt(paramVal[i]);
} catch( NumberFormatException nfe ) {}
}
return params;
}
public void
_jspService(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException
{
com.caucho.jsp.QPageContext pageContext = (com.caucho.jsp.QPageContext) com.caucho.jsp.QJspFactory.create().getPageContext(this, request, response, null, true, 8192, true);
javax.servlet.jsp.JspWriter out = (javax.servlet.jsp.JspWriter) pageContext.getOut();
javax.servlet.ServletConfig config = getServletConfig();
javax.servlet.Servlet page = this;
javax.servlet.http.HttpSession session = pageContext.getSession();
javax.servlet.ServletContext application = pageContext.getServletContext();
response.setContentType("text/html");
try {
pageContext.write(_jsp_string0, 0, _jsp_string0.length);
/**
* $RCSfile: groupPerms.jsp,v $
* $Revision: 1.3.2.3 $
* $Date: 2001/03/21 20:49:26 $
*/
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
com.coolservlets.forum.util.admin.AdminBean adminBean;
synchronized (session) {
adminBean = (com.coolservlets.forum.util.admin.AdminBean) session.getValue("adminBean");
if (adminBean == null) {
adminBean = new com.coolservlets.forum.util.admin.AdminBean();
session.putValue("adminBean", adminBean);
}
}
pageContext.write(_jsp_string2, 0, _jsp_string2.length);
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
////////////////////////////////
// Jive authorization check
// check the bean for the existence of an authorization token.
// Its existence proves the user is valid. If it's not found, redirect
// to the login page
Authorization authToken = adminBean.getAuthToken();
if( authToken == null ) {
response.sendRedirect( "login.jsp" );
return;
}
pageContext.write(_jsp_string2, 0, _jsp_string2.length);
////////////////////
// Security check
// make sure the user is authorized to administer users:
ForumFactory forumFactory = ForumFactory.getInstance(authToken);
boolean isSystemAdmin = ((Boolean)session.getValue("jiveAdmin.systemAdmin")).booleanValue();
boolean isGroupAdmin = ((Boolean)session.getValue("jiveAdmin.groupAdmin")).booleanValue();
// redirect to error page if we're not a group admin or a system admin
if( !isGroupAdmin && !isSystemAdmin ) {
request.setAttribute("message","No permission to administer groups");
response.sendRedirect("error.jsp");
return;
}
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
////////////////////
// get parameters
int groupID = ParamUtils.getIntParameter(request,"group",-1);
boolean doAction = ParamUtils.getBooleanParameter(request,"doAction");
String groupAdminMode = getParameterMode(ParamUtils.getParameter(request,"groupAdminMode"));
String groupUserMode = getParameterMode(ParamUtils.getParameter(request,"groupUserMode"));
int[] groupAdminsParam = getIntListboxParams(request.getParameterValues("groupAdmins"));
//int[] allAdminsParam = getIntListboxParams(request.getParameterValues("allAdmins"));
int[] groupUsersParam = getIntListboxParams(request.getParameterValues("groupUsers"));
//int[] allUsersParam = getIntListboxParams(request.getParameterValues("allUsers"));
String allAdminsUsername = ParamUtils.getParameter(request,"allAdminsUsername");
String allUsersUsername = ParamUtils.getParameter(request,"allUsersUsername");
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
/////////////////////
// other page variables
boolean addGroupAdmin = (groupAdminMode.equals("add"));
boolean removeGroupAdmin = (groupAdminMode.equals("remove"));
boolean addGroupUser = (groupUserMode.equals("add"));
boolean removeGroupUser = (groupUserMode.equals("remove"));
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
///////////////////////
// error variables
boolean errorGroupNotFound = false;
boolean errorNoPermission = false;
boolean errors = false;
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
//////////////////////////////////
// global variables
ProfileManager manager = forumFactory.getProfileManager();
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
/////////////////////
// try to load the group from the passed in group id
Group group = null;
try {
group = manager.getGroup(groupID);
}
catch( GroupNotFoundException gnfe ) {
response.sendRedirect("error.jsp?msg="
+ URLEncoder.encode("Group " + groupID + " not found") );
return;
}
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
/////////////////////
// this group properties
String groupName = group.getName();
String groupDescription = group.getDescription();
int userCount = group.getMemberCount();
Iterator adminIterator = group.administrators();
Iterator allAdmins = manager.users();
Iterator userIterator = group.members();
Iterator allUsers = manager.users();
pageContext.write(_jsp_string3, 0, _jsp_string3.length);
/////////////////////////
// do an action!
if( doAction ) {
// add a group administrator
if( addGroupAdmin ) {
try {
User admin = manager.getUser(allAdminsUsername);
group.addAdministrator(admin);
}
catch( UserNotFoundException unfe ) {}
catch( UnauthorizedException ue ) {}
}
// remove a group administrator
else if( removeGroupAdmin ) {
for( int i=0; i<groupAdminsParam.length; i++ ) {
try {
User admin = manager.getUser(groupAdminsParam[i]);
group.removeAdministrator(admin);
}
catch( UserNotFoundException unfe ) {}
catch( UnauthorizedException ue ) {}
}
}
// add a group user
else if( addGroupUser ) {
try {
User user = manager.getUser(allUsersUsername);
group.addMember(user);
}
catch( UserNotFoundException unfe ) {}
catch( UnauthorizedException ue ) {}
}
// remove a group user
else if( removeGroupUser ) {
System.err.println( "in removegroupuser" );
for( int i=0; i<groupUsersParam.length; i++ ) {
try {
System.out.println( "remove: " + groupUsersParam[i] );
User user = manager.getUser(groupUsersParam[i]);
group.removeMember(user);
}
catch( UserNotFoundException unfe ) {}
catch( UnauthorizedException ue ) {}
}
}
}
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
////////////////////
// if we did something, redirect to this page again (since we're doing POSTS
// on the form)
// uncommented so i can debug parameters!!
if( doAction ) {
response.sendRedirect("groupPerms.jsp?group="+groupID);
return;
}
pageContext.write(_jsp_string4, 0, _jsp_string4.length);
///////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -