From 41cffba4298d61383d0dd99857429960a4ca3d44 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 04 Nov 2011 23:00:19 -0400
Subject: [PATCH] Refinements to search dialog and null checks in cell renderers

---
 src/com/gitblit/SyndicationServlet.java |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/com/gitblit/SyndicationServlet.java b/src/com/gitblit/SyndicationServlet.java
index af0fab7..39e37ca 100644
--- a/src/com/gitblit/SyndicationServlet.java
+++ b/src/com/gitblit/SyndicationServlet.java
@@ -33,7 +33,6 @@
 import com.gitblit.models.SyndicatedEntryModel;
 import com.gitblit.utils.HttpUtils;
 import com.gitblit.utils.JGitUtils;
-import com.gitblit.utils.JGitUtils.SearchType;
 import com.gitblit.utils.StringUtils;
 import com.gitblit.utils.SyndicationUtils;
 
@@ -130,10 +129,11 @@
 		String repositoryName = url;
 		String objectId = request.getParameter("h");
 		String l = request.getParameter("l");
+		String page = request.getParameter("pg");
 		String searchString = request.getParameter("s");
-		SearchType searchType = SearchType.COMMIT;
+		Constants.SearchType searchType = Constants.SearchType.COMMIT;
 		if (!StringUtils.isEmpty(request.getParameter("st"))) {
-			SearchType type = SearchType.forName(request.getParameter("st"));
+			Constants.SearchType type = Constants.SearchType.forName(request.getParameter("st"));
 			if (type != null) {
 				searchType = type;
 			}
@@ -148,6 +148,13 @@
 			} catch (NumberFormatException x) {
 			}
 		}
+		int offset = 0;
+		if (!StringUtils.isEmpty(page)) {
+			try {
+				offset = length * Integer.parseInt(page);
+			} catch (NumberFormatException x) {
+			}
+		}
 
 		response.setContentType("application/rss+xml; charset=UTF-8");
 		Repository repository = GitBlit.self().getRepository(repositoryName);
@@ -155,11 +162,11 @@
 		List<RevCommit> commits;
 		if (StringUtils.isEmpty(searchString)) {
 			// standard log/history lookup
-			commits = JGitUtils.getRevLog(repository, objectId, 0, length);
+			commits = JGitUtils.getRevLog(repository, objectId, offset, length);
 		} else {
 			// repository search
-			commits = JGitUtils.searchRevlogs(repository, objectId, searchString, searchType, 0,
-					length);
+			commits = JGitUtils.searchRevlogs(repository, objectId, searchString, searchType,
+					offset, length);
 		}
 		Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(repository);
 		List<SyndicatedEntryModel> entries = new ArrayList<SyndicatedEntryModel>();

--
Gitblit v1.9.1