Permalink
Browse files

Merge pull request #467 from tuub/DS-1860

Fixes DS-1860 to show all collections and communities in community list.
  • Loading branch information...
helix84 committed Feb 17, 2014
2 parents e134c1a + aaacf61 commit a9ebb5a6ba071a6db900da68263744b200c02469
Showing with 52 additions and 26 deletions.
  1. +52 −26 dspace-jspui/src/main/java/org/dspace/app/webui/servlet/CommunityListServlet.java
@@ -11,6 +11,7 @@
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.locks.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -33,46 +34,71 @@
*/
public class CommunityListServlet extends DSpaceServlet
{
// This will map community IDs to arrays of collections
private Map<Integer, Collection[]> colMap;
// This will map communityIDs to arrays of sub-communities
private Map<Integer, Community[]> commMap;
private static final Object staticLock = new Object();
/** log4j category */
private static Logger log = Logger.getLogger(CommunityListServlet.class);
protected void doDSGet(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
SQLException, AuthorizeException
{
log.info(LogManager.getHeader(context, "view_community_list", ""));
{
synchronized (staticLock)
{
colMap = new HashMap<Integer, Collection[]>();
commMap = new HashMap<Integer, Community[]>();
// This will map community IDs to arrays of collections
Map<Integer, Collection[]> colMap = new HashMap<Integer, Collection[]>();
log.info(LogManager.getHeader(context, "view_community_list", ""));
// This will map communityIDs to arrays of sub-communities
Map<Integer, Community[]> commMap = new HashMap<Integer, Community[]>();
Community[] communities = Community.findAllTop(context);
Community[] communities = Community.findAllTop(context);
for (int com = 0; com < communities.length; com++)
{
build(communities[com]);
}
for (int com = 0; com < communities.length; com++)
{
Integer comID = Integer.valueOf(communities[com].getID());
// can they admin communities?
if (AuthorizeManager.isAdmin(context))
{
// set a variable to create an edit button
request.setAttribute("admin_button", Boolean.TRUE);
}
// Find collections in community
Collection[] colls = communities[com].getCollections();
colMap.put(comID, colls);
request.setAttribute("communities", communities);
request.setAttribute("collections.map", colMap);
request.setAttribute("subcommunities.map", commMap);
JSPManager.showJSP(request, response, "/community-list.jsp");
}
}
/*
* Get all subcommunities and collections from a community
*/
private void build(Community c) throws SQLException {
// Find subcommunties in community
Community[] comms = communities[com].getSubcommunities();
commMap.put(comID, comms);
}
Integer comID = Integer.valueOf(c.getID());
// Find collections in community
Collection[] colls = c.getCollections();
colMap.put(comID, colls);
// can they admin communities?
if (AuthorizeManager.isAdmin(context))
// Find subcommunties in community
Community[] comms = c.getSubcommunities();
// Get all subcommunities for each communities if they have some
if (comms.length > 0)
{
// set a variable to create an edit button
request.setAttribute("admin_button", Boolean.TRUE);
commMap.put(comID, comms);
for (int sub = 0; sub < comms.length; sub++) {
build(comms[sub]);
}
}
request.setAttribute("communities", communities);
request.setAttribute("collections.map", colMap);
request.setAttribute("subcommunities.map", commMap);
JSPManager.showJSP(request, response, "/community-list.jsp");
}
}

0 comments on commit a9ebb5a

Please sign in to comment.