mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-09 19:13:18 +00:00
Merge pull request #467 from tuub/DS-1860
Fixes DS-1860 to show all collections and communities in community list.
This commit is contained in:
@@ -11,6 +11,7 @@ import java.io.IOException;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.locks.*;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -33,6 +34,14 @@ import org.dspace.core.LogManager;
|
|||||||
*/
|
*/
|
||||||
public class CommunityListServlet extends DSpaceServlet
|
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 */
|
/** log4j category */
|
||||||
private static Logger log = Logger.getLogger(CommunityListServlet.class);
|
private static Logger log = Logger.getLogger(CommunityListServlet.class);
|
||||||
|
|
||||||
@@ -40,27 +49,18 @@ public class CommunityListServlet extends DSpaceServlet
|
|||||||
HttpServletResponse response) throws ServletException, IOException,
|
HttpServletResponse response) throws ServletException, IOException,
|
||||||
SQLException, AuthorizeException
|
SQLException, AuthorizeException
|
||||||
{
|
{
|
||||||
|
synchronized (staticLock)
|
||||||
|
{
|
||||||
|
colMap = new HashMap<Integer, Collection[]>();
|
||||||
|
commMap = new HashMap<Integer, Community[]>();
|
||||||
|
|
||||||
log.info(LogManager.getHeader(context, "view_community_list", ""));
|
log.info(LogManager.getHeader(context, "view_community_list", ""));
|
||||||
|
|
||||||
// This will map community IDs to arrays of collections
|
|
||||||
Map<Integer, Collection[]> colMap = new HashMap<Integer, Collection[]>();
|
|
||||||
|
|
||||||
// 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++)
|
for (int com = 0; com < communities.length; com++)
|
||||||
{
|
{
|
||||||
Integer comID = Integer.valueOf(communities[com].getID());
|
build(communities[com]);
|
||||||
|
|
||||||
// Find collections in community
|
|
||||||
Collection[] colls = communities[com].getCollections();
|
|
||||||
colMap.put(comID, colls);
|
|
||||||
|
|
||||||
// Find subcommunties in community
|
|
||||||
Community[] comms = communities[com].getSubcommunities();
|
|
||||||
commMap.put(comID, comms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// can they admin communities?
|
// can they admin communities?
|
||||||
@@ -75,4 +75,30 @@ public class CommunityListServlet extends DSpaceServlet
|
|||||||
request.setAttribute("subcommunities.map", commMap);
|
request.setAttribute("subcommunities.map", commMap);
|
||||||
JSPManager.showJSP(request, response, "/community-list.jsp");
|
JSPManager.showJSP(request, response, "/community-list.jsp");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Get all subcommunities and collections from a community
|
||||||
|
*/
|
||||||
|
private void build(Community c) throws SQLException {
|
||||||
|
|
||||||
|
Integer comID = Integer.valueOf(c.getID());
|
||||||
|
|
||||||
|
// Find collections in community
|
||||||
|
Collection[] colls = c.getCollections();
|
||||||
|
colMap.put(comID, colls);
|
||||||
|
|
||||||
|
// Find subcommunties in community
|
||||||
|
Community[] comms = c.getSubcommunities();
|
||||||
|
|
||||||
|
// Get all subcommunities for each communities if they have some
|
||||||
|
if (comms.length > 0)
|
||||||
|
{
|
||||||
|
commMap.put(comID, comms);
|
||||||
|
|
||||||
|
for (int sub = 0; sub < comms.length; sub++) {
|
||||||
|
|
||||||
|
build(comms[sub]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user