From edeab95cac16e5f17cfcd75a9969d8708bf360ab Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Mon, 12 May 2014 09:22:04 -0400
Subject: [PATCH] Documentation

---
 src/main/java/com/gitblit/utils/SyndicationUtils.java |   69 +++++++++++++++++++++++++++++++---
 1 files changed, 63 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/gitblit/utils/SyndicationUtils.java b/src/main/java/com/gitblit/utils/SyndicationUtils.java
index d01d469..93e9321 100644
--- a/src/main/java/com/gitblit/utils/SyndicationUtils.java
+++ b/src/main/java/com/gitblit/utils/SyndicationUtils.java
@@ -25,6 +25,7 @@
 import java.util.List;
 
 import com.gitblit.Constants;
+import com.gitblit.Constants.FeedObjectType;
 import com.gitblit.GitBlitException;
 import com.gitblit.models.FeedEntryModel;
 import com.sun.syndication.feed.synd.SyndCategory;
@@ -43,15 +44,15 @@
 
 /**
  * Utility class for RSS feeds.
- * 
+ *
  * @author James Moger
- * 
+ *
  */
 public class SyndicationUtils {
 
 	/**
 	 * Outputs an RSS feed of the list of entries to the outputstream.
-	 * 
+	 *
 	 * @param hostUrl
 	 * @param feedLink
 	 * @param title
@@ -118,7 +119,7 @@
 
 	/**
 	 * Reads a Gitblit RSS feed.
-	 * 
+	 *
 	 * @param url
 	 *            the url of the Gitblit server
 	 * @param repository
@@ -137,6 +138,59 @@
 	 */
 	public static List<FeedEntryModel> readFeed(String url, String repository, String branch,
 			int numberOfEntries, int page, String username, char[] password) throws IOException {
+		return readFeed(url, repository, branch, FeedObjectType.COMMIT, numberOfEntries,
+				page, username, password);
+	}
+
+	/**
+	 * Reads tags from the specified repository.
+	 *
+	 * @param url
+	 *            the url of the Gitblit server
+	 * @param repository
+	 *            the repository name
+	 * @param branch
+	 *            the branch name (optional)
+	 * @param numberOfEntries
+	 *            the number of entries to retrieve. if <= 0 the server default
+	 *            is used.
+	 * @param page
+	 *            0-indexed. used to paginate the results.
+	 * @param username
+	 * @param password
+	 * @return a list of SyndicationModel entries
+	 * @throws {@link IOException}
+	 */
+	public static List<FeedEntryModel> readTags(String url, String repository,
+			int numberOfEntries, int page, String username, char[] password) throws IOException {
+		return readFeed(url, repository, null, FeedObjectType.TAG, numberOfEntries,
+				page, username, password);
+	}
+
+	/**
+	 * Reads a Gitblit RSS feed.
+	 *
+	 * @param url
+	 *            the url of the Gitblit server
+	 * @param repository
+	 *            the repository name
+	 * @param branch
+	 *            the branch name (optional)
+	 * @param objectType
+	 *            the object type to return (optional, COMMIT assummed)
+	 * @param numberOfEntries
+	 *            the number of entries to retrieve. if <= 0 the server default
+	 *            is used.
+	 * @param page
+	 *            0-indexed. used to paginate the results.
+	 * @param username
+	 * @param password
+	 * @return a list of SyndicationModel entries
+	 * @throws {@link IOException}
+	 */
+	private static List<FeedEntryModel> readFeed(String url, String repository, String branch,
+			FeedObjectType objectType, int numberOfEntries, int page, String username,
+			char[] password) throws IOException {
 		// build feed url
 		List<String> parameters = new ArrayList<String>();
 		if (numberOfEntries > 0) {
@@ -148,12 +202,15 @@
 		if (!StringUtils.isEmpty(branch)) {
 			parameters.add("h=" + branch);
 		}
+		if (objectType != null) {
+			parameters.add("ot=" + objectType.name());
+		}
 		return readFeed(url, parameters, repository, branch, username, password);
 	}
 
 	/**
 	 * Reads a Gitblit RSS search feed.
-	 * 
+	 *
 	 * @param url
 	 *            the url of the Gitblit server
 	 * @param repository
@@ -195,7 +252,7 @@
 
 	/**
 	 * Reads a Gitblit RSS feed.
-	 * 
+	 *
 	 * @param url
 	 *            the url of the Gitblit server
 	 * @param parameters

--
Gitblit v1.9.1