use of com.gitblit.models.FeedModel in project gitblit by gitblit.
the class RpcUtils method getBranchFeeds.
/**
* Retrieves a list of available branch feeds in the Gitblit server.
*
* @param serverUrl
* @param account
* @param password
* @return
* @throws IOException
*/
public static List<FeedModel> getBranchFeeds(String serverUrl, String account, char[] password) throws IOException {
List<FeedModel> feeds = new ArrayList<FeedModel>();
Map<String, Collection<String>> allBranches = getBranches(serverUrl, account, password);
for (Map.Entry<String, Collection<String>> entry : allBranches.entrySet()) {
for (String branch : entry.getValue()) {
FeedModel feed = new FeedModel();
feed.repository = entry.getKey();
feed.branch = branch;
feeds.add(feed);
}
}
return feeds;
}
use of com.gitblit.models.FeedModel in project gitblit by gitblit.
the class GitblitClient method getBranches.
public List<String> getBranches(String repository) {
List<FeedModel> feeds = getAvailableFeeds(repository);
List<String> branches = new ArrayList<String>();
for (FeedModel feed : feeds) {
branches.add(feed.branch);
}
Collections.sort(branches);
return branches;
}
use of com.gitblit.models.FeedModel in project gitblit by gitblit.
the class GitblitClient method refreshSubscribedFeeds.
public List<FeedEntryModel> refreshSubscribedFeeds(int page) throws IOException {
Set<FeedEntryModel> allEntries = new HashSet<FeedEntryModel>();
if (reg.feeds.size() > 0) {
for (FeedModel feed : reg.feeds) {
feed.lastRefreshDate = feed.currentRefreshDate;
feed.currentRefreshDate = new Date();
List<FeedEntryModel> entries = SyndicationUtils.readFeed(url, feed.repository, feed.branch, -1, page, account, password);
allEntries.addAll(entries);
}
}
reg.cacheFeeds();
syndicatedEntries.clear();
syndicatedEntries.addAll(allEntries);
Collections.sort(syndicatedEntries);
return syndicatedEntries;
}
use of com.gitblit.models.FeedModel in project gitblit by gitblit.
the class GitblitManager method saveRegistration.
@Override
public boolean saveRegistration(String name, GitblitRegistration reg) {
try {
StoredConfig config = getConfig();
if (!StringUtils.isEmpty(name) && !name.equals(reg.name)) {
// delete old registration
registrations.remove(name);
config.unsetSection(SERVER, name);
}
// update registration
config.setString(SERVER, reg.name, "url", reg.url);
config.setString(SERVER, reg.name, "account", reg.account);
if (reg.savePassword) {
config.setString(SERVER, reg.name, "password", Base64.encodeBytes(new String(reg.password).getBytes("UTF-8")));
} else {
config.setString(SERVER, reg.name, "password", "");
}
if (reg.lastLogin != null) {
config.setString(SERVER, reg.name, "lastLogin", dateFormat.format(reg.lastLogin));
}
// serialize the feed definitions
List<String> definitions = new ArrayList<String>();
for (FeedModel feed : reg.feeds) {
definitions.add(feed.toString());
}
if (definitions.size() > 0) {
config.setStringList(SERVER, reg.name, FEED, definitions);
}
config.save();
return true;
} catch (Throwable t) {
Utils.showException(GitblitManager.this, t);
}
return false;
}
use of com.gitblit.models.FeedModel in project gitblit by gitblit.
the class GitblitManager method loadRegistrations.
private void loadRegistrations() {
try {
StoredConfig config = getConfig();
Set<String> servers = config.getSubsections(SERVER);
for (String server : servers) {
Date lastLogin = new Date(0);
String date = config.getString(SERVER, server, "lastLogin");
if (!StringUtils.isEmpty(date)) {
lastLogin = dateFormat.parse(date);
}
String url = config.getString(SERVER, server, "url");
String account = config.getString(SERVER, server, "account");
char[] password;
String pw = config.getString(SERVER, server, "password");
if (StringUtils.isEmpty(pw)) {
password = new char[0];
} else {
password = new String(Base64.decode(pw)).toCharArray();
}
GitblitRegistration reg = new GitblitRegistration(server, url, account, password) {
private static final long serialVersionUID = 1L;
@Override
protected void cacheFeeds() {
writeFeedCache(this);
}
};
String[] feeds = config.getStringList(SERVER, server, FEED);
if (feeds != null) {
// deserialize the field definitions
for (String definition : feeds) {
FeedModel feed = new FeedModel(definition);
reg.feeds.add(feed);
}
}
reg.lastLogin = lastLogin;
loadFeedCache(reg);
registrations.put(reg.name, reg);
}
} catch (Throwable t) {
Utils.showException(GitblitManager.this, t);
}
}
Aggregations