1 40 package org.dspace.app.webui.servlet; 41 42 import java.io.IOException ; 43 import java.sql.SQLException ; 44 import java.util.HashMap ; 45 import java.util.Map ; 46 47 import javax.servlet.ServletException ; 48 import javax.servlet.http.HttpServletRequest ; 49 import javax.servlet.http.HttpServletResponse ; 50 51 import org.apache.log4j.Logger; 52 import org.dspace.app.webui.util.JSPManager; 53 import org.dspace.authorize.AuthorizeException; 54 import org.dspace.authorize.AuthorizeManager; 55 import org.dspace.content.Collection; 56 import org.dspace.content.Community; 57 import org.dspace.core.Context; 58 import org.dspace.core.LogManager; 59 60 66 public class CommunityListServlet extends DSpaceServlet 67 { 68 69 private static Logger log = Logger.getLogger(CommunityListServlet.class); 70 71 protected void doDSGet(Context context, HttpServletRequest request, 72 HttpServletResponse response) throws ServletException , IOException , 73 SQLException , AuthorizeException 74 { 75 log.info(LogManager.getHeader(context, "view_community_list", "")); 76 77 Map colMap = new HashMap (); 79 80 Map commMap = new HashMap (); 82 83 Community[] communities = Community.findAllTop(context); 84 85 for (int com = 0; com < communities.length; com++) 86 { 87 Integer comID = new Integer (communities[com].getID()); 88 89 Collection[] colls = communities[com].getCollections(); 91 colMap.put(comID, colls); 92 93 Community[] comms = communities[com].getSubcommunities(); 95 commMap.put(comID, comms); 96 } 97 98 if (AuthorizeManager.isAdmin(context)) 100 { 101 request.setAttribute("admin_button", new Boolean (true)); 103 } 104 105 request.setAttribute("communities", communities); 106 request.setAttribute("collections.map", colMap); 107 request.setAttribute("subcommunities.map", commMap); 108 JSPManager.showJSP(request, response, "/community-list.jsp"); 109 } 110 } 111 | Popular Tags |