1 40 package org.dspace.app.webui.servlet; 41 42 import java.io.IOException ; 43 import java.sql.SQLException ; 44 45 import javax.servlet.ServletException ; 46 import javax.servlet.http.HttpServletRequest ; 47 import javax.servlet.http.HttpServletResponse ; 48 49 import org.apache.log4j.Logger; 50 import org.dspace.app.webui.util.JSPManager; 51 import org.dspace.app.webui.util.UIUtil; 52 import org.dspace.authorize.AuthorizeException; 53 import org.dspace.browse.Browse; 54 import org.dspace.browse.BrowseInfo; 55 import org.dspace.browse.BrowseScope; 56 import org.dspace.content.Collection; 57 import org.dspace.content.Community; 58 import org.dspace.core.Context; 59 import org.dspace.core.LogManager; 60 61 66 public class ItemsBySubjectServlet extends DSpaceServlet 67 { 68 69 private static Logger log = Logger.getLogger(ItemsBySubjectServlet.class); 70 71 protected void doDSGet(Context context, HttpServletRequest request, 72 HttpServletResponse response) throws ServletException , IOException , 73 SQLException , AuthorizeException 74 { 75 BrowseScope scope = new BrowseScope(context); 77 78 String logInfo = ""; 80 81 String subject = request.getParameter("subject"); 83 String order = request.getParameter("order"); 84 85 boolean orderByTitle; 87 88 if ((order != null) && order.equalsIgnoreCase("title")) 89 { 90 orderByTitle = true; 91 logInfo = "order=title"; 92 } 93 else 94 { 95 orderByTitle = false; 96 logInfo = "order=date"; 97 } 98 99 Community community = UIUtil.getCommunityLocation(request); 101 Collection collection = UIUtil.getCollectionLocation(request); 102 103 if (collection != null) 104 { 105 logInfo = logInfo + ",collection_id=" + collection.getID(); 106 scope.setScope(collection); 107 } 108 else if (community != null) 109 { 110 logInfo = logInfo + ",community_id=" + community.getID(); 111 scope.setScope(community); 112 } 113 114 if (subject == null) 116 { 117 subject = ""; 118 } 119 120 scope.setFocus(subject); 122 123 BrowseInfo browseInfo = Browse.getItemsBySubject(scope, orderByTitle); 124 125 log.info(LogManager.getHeader(context, "items_by_subject", logInfo 126 + ",result_count=" + browseInfo.getResultCount())); 127 128 request.setAttribute("community", community); 130 request.setAttribute("collection", collection); 131 request.setAttribute("subject", subject); 132 request.setAttribute("order.by.title", new Boolean (orderByTitle)); 133 request.setAttribute("browse.info", browseInfo); 134 135 JSPManager.showJSP(request, response, "/browse/items-by-subject.jsp"); 136 } 137 } 138 | Popular Tags |