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 67 public class ItemsByAuthorServlet extends DSpaceServlet 68 { 69 70 private static Logger log = Logger.getLogger(ItemsByAuthorServlet.class); 71 72 protected void doDSGet(Context context, HttpServletRequest request, 73 HttpServletResponse response) throws ServletException , IOException , 74 SQLException , AuthorizeException 75 { 76 BrowseScope scope = new BrowseScope(context); 78 79 String logInfo = ""; 81 82 String author = request.getParameter("author"); 84 String order = request.getParameter("order"); 85 86 boolean orderByTitle; 88 89 if ((order != null) && order.equalsIgnoreCase("title")) 90 { 91 orderByTitle = true; 92 logInfo = "order=title"; 93 } 94 else 95 { 96 orderByTitle = false; 97 logInfo = "order=date"; 98 } 99 100 Community community = UIUtil.getCommunityLocation(request); 102 Collection collection = UIUtil.getCollectionLocation(request); 103 104 if (collection != null) 105 { 106 logInfo = logInfo + ",collection_id=" + collection.getID(); 107 scope.setScope(collection); 108 } 109 else if (community != null) 110 { 111 logInfo = logInfo + ",community_id=" + community.getID(); 112 scope.setScope(community); 113 } 114 115 if (author == null) 117 { 118 author = ""; 119 } 120 121 scope.setFocus(author); 123 124 BrowseInfo browseInfo = Browse.getItemsByAuthor(scope, orderByTitle); 125 126 log.info(LogManager.getHeader(context, "items_by_author", logInfo 127 + ",result_count=" + browseInfo.getResultCount())); 128 129 request.setAttribute("community", community); 131 request.setAttribute("collection", collection); 132 request.setAttribute("author", author); 133 request.setAttribute("order.by.title", new Boolean (orderByTitle)); 134 request.setAttribute("browse.info", browseInfo); 135 136 JSPManager.showJSP(request, response, "/browse/items-by-author.jsp"); 137 } 138 } 139 | Popular Tags |