changes: ~
additions:
- Add FORK_REPOSITORY RPC request type (issue-371, pr-161, ticket-65)
+ - Add object type (ot) parameter for RSS queries to retrieve tag details (pr-165, ticket-66)
dependencyChanges: ~
contributors:
- Manisha Gayathri
+ - Gerard Smyth
}
#
/**\r
* Enumeration of the feed content object types.\r
*/\r
- public static enum FeedContentObjectType {\r
+ public static enum FeedObjectType {\r
COMMIT, TAG;\r
\r
- public static FeedContentObjectType forName(String name) {\r
- for (FeedContentObjectType type : values()) {\r
+ public static FeedObjectType forName(String name) {\r
+ for (FeedObjectType type : values()) {\r
if (type.name().equalsIgnoreCase(name)) {\r
return type;\r
}\r
}\r
}\r
\r
- Constants.FeedContentObjectType objectType = Constants.FeedContentObjectType.COMMIT;\r
+ Constants.FeedObjectType objectType = Constants.FeedObjectType.COMMIT;\r
if (!StringUtils.isEmpty(request.getParameter("ot"))) {\r
- Constants.FeedContentObjectType type = Constants.FeedContentObjectType.forName(request.getParameter("ot"));\r
+ Constants.FeedObjectType type = Constants.FeedObjectType.forName(request.getParameter("ot"));\r
if (type != null) {\r
objectType = type;\r
}\r
feedDescription = model.description;\r
}\r
\r
- if (objectType == Constants.FeedContentObjectType.TAG) {\r
+ if (objectType == Constants.FeedObjectType.TAG) {\r
\r
String urlPattern;\r
if (mountParameters) {\r
import java.util.List;\r
\r
import com.gitblit.Constants;\r
+import com.gitblit.Constants.FeedObjectType;\r
import com.gitblit.GitBlitException;\r
import com.gitblit.models.FeedEntryModel;\r
import com.sun.syndication.feed.synd.SyndCategory;\r
*/\r
public static List<FeedEntryModel> readFeed(String url, String repository, String branch,\r
int numberOfEntries, int page, String username, char[] password) throws IOException {\r
+ return readFeed(url, repository, branch, FeedObjectType.COMMIT, numberOfEntries,\r
+ page, username, password);\r
+ }\r
+\r
+ /**\r
+ * Reads tags from the specified repository.\r
+ *\r
+ * @param url\r
+ * the url of the Gitblit server\r
+ * @param repository\r
+ * the repository name\r
+ * @param branch\r
+ * the branch name (optional)\r
+ * @param numberOfEntries\r
+ * the number of entries to retrieve. if <= 0 the server default\r
+ * is used.\r
+ * @param page\r
+ * 0-indexed. used to paginate the results.\r
+ * @param username\r
+ * @param password\r
+ * @return a list of SyndicationModel entries\r
+ * @throws {@link IOException}\r
+ */\r
+ public static List<FeedEntryModel> readTags(String url, String repository,\r
+ int numberOfEntries, int page, String username, char[] password) throws IOException {\r
+ return readFeed(url, repository, null, FeedObjectType.TAG, numberOfEntries,\r
+ page, username, password);\r
+ }\r
+\r
+ /**\r
+ * Reads a Gitblit RSS feed.\r
+ *\r
+ * @param url\r
+ * the url of the Gitblit server\r
+ * @param repository\r
+ * the repository name\r
+ * @param branch\r
+ * the branch name (optional)\r
+ * @param objectType\r
+ * the object type to return (optional, COMMIT assummed)\r
+ * @param numberOfEntries\r
+ * the number of entries to retrieve. if <= 0 the server default\r
+ * is used.\r
+ * @param page\r
+ * 0-indexed. used to paginate the results.\r
+ * @param username\r
+ * @param password\r
+ * @return a list of SyndicationModel entries\r
+ * @throws {@link IOException}\r
+ */\r
+ private static List<FeedEntryModel> readFeed(String url, String repository, String branch,\r
+ FeedObjectType objectType, int numberOfEntries, int page, String username,\r
+ char[] password) throws IOException {\r
// build feed url\r
List<String> parameters = new ArrayList<String>();\r
if (numberOfEntries > 0) {\r
if (!StringUtils.isEmpty(branch)) {\r
parameters.add("h=" + branch);\r
}\r
+ if (objectType != null) {\r
+ parameters.add("ot=" + objectType.name());\r
+ }\r
return readFeed(url, parameters, repository, branch, username, password);\r
}\r
\r
<tr><th>url parameter</th><th>default</th><th>description</th></tr>\r
<tr><td colspan='3'><b>standard query</b></td></tr>\r
<tr><td><em>repository</em></td><td><em>required</em></td><td>repository name is part of the url (see examples below)</td></tr>\r
+<tr><td>ot=</td><td><em>optional</em><br/>default: COMMIT</td><td>object type to return in results. COMMIT or TAG</td></tr>\r
<tr><td>h=</td><td><em>optional</em><br/>default: HEAD</td><td>starting branch, ref, or commit id</td></tr>\r
<tr><td>l=</td><td><em>optional</em><br/>default: web.syndicationEntries</td><td>maximum return count</td></tr>\r
<tr><td>pg=</td><td><em>optional</em><br/>default: 0</td><td>page number for paging<br/>(offset into history = pagenumber*maximum return count)</td></tr>\r
import java.util.HashSet;\r
import java.util.List;\r
import java.util.Set;\r
+import java.util.concurrent.atomic.AtomicBoolean;\r
\r
+import org.junit.AfterClass;\r
+import org.junit.BeforeClass;\r
import org.junit.Test;\r
\r
import com.gitblit.Constants.SearchType;\r
\r
public class SyndicationUtilsTest extends GitblitUnitTest {\r
\r
+ private static final AtomicBoolean started = new AtomicBoolean(false);\r
+\r
+ @BeforeClass\r
+ public static void startGitblit() throws Exception {\r
+ started.set(GitBlitSuite.startGitblit());\r
+ }\r
+\r
+ @AfterClass\r
+ public static void stopGitblit() throws Exception {\r
+ if (started.get()) {\r
+ GitBlitSuite.stopGitblit();\r
+ }\r
+ }\r
+\r
@Test\r
public void testSyndication() throws Exception {\r
List<FeedEntryModel> entries = new ArrayList<FeedEntryModel>();\r
}\r
\r
@Test\r
- public void testFeedRead() throws Exception {\r
+ public void testFeedReadCommits() throws Exception {\r
Set<String> links = new HashSet<String>();\r
for (int i = 0; i < 2; i++) {\r
List<FeedEntryModel> feed = SyndicationUtils.readFeed(GitBlitSuite.url, "ticgit.git",\r
assertEquals("Feed pagination failed", 10, links.size());\r
}\r
\r
+ @Test\r
+ public void testFeedReadTags() throws Exception {\r
+ Set<String> links = new HashSet<String>();\r
+ for (int i = 0; i < 2; i++) {\r
+ List<FeedEntryModel> feed = SyndicationUtils.readTags(GitBlitSuite.url, "test/gitective.git",\r
+ 5, i, GitBlitSuite.account, GitBlitSuite.password.toCharArray());\r
+ assertTrue(feed != null);\r
+ assertTrue(feed.size() > 0);\r
+ assertEquals(5, feed.size());\r
+ for (FeedEntryModel entry : feed) {\r
+ links.add(entry.link);\r
+ }\r
+ }\r
+ // confirm we have 10 unique tags\r
+ assertEquals("Feed pagination failed", 10, links.size());\r
+ }\r
+\r
@Test\r
public void testSearchFeedRead() throws Exception {\r
List<FeedEntryModel> feed = SyndicationUtils\r