use of com.gitblit.models.RepositoryModel in project gitblit by gitblit.
the class FederationManager method createFederationProposal.
/**
* Creates a proposal from the token.
*
* @param gitblitUrl
* the url of this Gitblit instance
* @param token
* @return a potential proposal
*/
@Override
public FederationProposal createFederationProposal(String gitblitUrl, String token) {
FederationToken tokenType = FederationToken.REPOSITORIES;
for (FederationToken type : FederationToken.values()) {
if (token.equals(getFederationToken(type))) {
tokenType = type;
break;
}
}
Map<String, RepositoryModel> repositories = getRepositories(gitblitUrl, token);
FederationProposal proposal = new FederationProposal(gitblitUrl, tokenType, token, repositories);
return proposal;
}
use of com.gitblit.models.RepositoryModel in project gitblit by gitblit.
the class RepositoryManager method getForkNetwork.
/**
* Returns the fork network for a repository by traversing up the fork graph
* to discover the root and then down through all children of the root node.
*
* @param repository
* @return a ForkModel
*/
@Override
public ForkModel getForkNetwork(String repository) {
if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) {
// find the root, cached
String key = getRepositoryKey(repository);
RepositoryModel model = repositoryListCache.get(key);
if (model == null) {
return null;
}
while (model.originRepository != null) {
String originKey = getRepositoryKey(model.originRepository);
model = repositoryListCache.get(originKey);
if (model == null) {
return null;
}
}
ForkModel root = getForkModelFromCache(model.name);
return root;
} else {
// find the root, non-cached
RepositoryModel model = getRepositoryModel(repository.toLowerCase());
while (model.originRepository != null) {
model = getRepositoryModel(model.originRepository);
}
ForkModel root = getForkModel(model.name);
return root;
}
}
use of com.gitblit.models.RepositoryModel in project gitblit by gitblit.
the class RepositoryManager method getRepositoryModels.
/**
* Returns the list of all repository models.
*
* @return list of all repository models
*/
@Override
public List<RepositoryModel> getRepositoryModels() {
long methodStart = System.currentTimeMillis();
List<String> list = getRepositoryList();
List<RepositoryModel> repositories = new ArrayList<RepositoryModel>();
for (String repo : list) {
RepositoryModel model = getRepositoryModel(repo);
if (model != null) {
repositories.add(model);
}
}
long duration = System.currentTimeMillis() - methodStart;
logger.info(MessageFormat.format("{0} repository models loaded in {1} msecs", duration));
return repositories;
}
use of com.gitblit.models.RepositoryModel in project gitblit by gitblit.
the class RepositoryManager method addToCachedRepositoryList.
/**
* Adds the repository to the list of cached repositories if Gitblit is
* configured to cache the repository list.
*
* @param model
*/
@Override
public void addToCachedRepositoryList(RepositoryModel model) {
if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) {
String key = getRepositoryKey(model.name);
repositoryListCache.put(key, model);
// update the fork origin repository with this repository clone
if (!StringUtils.isEmpty(model.originRepository)) {
String originKey = getRepositoryKey(model.originRepository);
if (repositoryListCache.containsKey(originKey)) {
RepositoryModel origin = repositoryListCache.get(originKey);
origin.addFork(model.name);
}
}
}
}
use of com.gitblit.models.RepositoryModel in project gitblit by gitblit.
the class UserPage method setup.
private void setup(PageParameters params) {
setupPage("", "");
// check to see if we should display a login message
boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, true);
if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {
authenticationError("Please login");
return;
}
String userName = WicketUtils.getUsername(params);
if (StringUtils.isEmpty(userName)) {
throw new GitblitRedirectException(GitBlitWebApp.get().getHomePage());
}
UserModel user = app().users().getUserModel(userName);
if (user == null) {
// construct a temporary user model
user = new UserModel(userName);
}
add(new UserTitlePanel("userTitlePanel", user, user.username));
UserModel sessionUser = GitBlitWebSession.get().getUser();
boolean isMyProfile = sessionUser != null && sessionUser.equals(user);
if (isMyProfile) {
addPreferences(user);
if (app().services().isServingSSH()) {
// show the SSH key management tab
addSshKeys(user);
} else {
// SSH daemon is disabled, hide keys tab
add(new Label("sshKeysLink").setVisible(false));
add(new Label("sshKeysTab").setVisible(false));
}
} else {
// visiting user
add(new Label("preferencesLink").setVisible(false));
add(new Label("preferencesTab").setVisible(false));
add(new Label("sshKeysLink").setVisible(false));
add(new Label("sshKeysTab").setVisible(false));
}
List<RepositoryModel> repositories = getRepositories(params);
Collections.sort(repositories, new Comparator<RepositoryModel>() {
@Override
public int compare(RepositoryModel o1, RepositoryModel o2) {
// reverse-chronological sort
return o2.lastChange.compareTo(o1.lastChange);
}
});
final ListDataProvider<RepositoryModel> dp = new ListDataProvider<RepositoryModel>(repositories);
DataView<RepositoryModel> dataView = new DataView<RepositoryModel>("repositoryList", dp) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(final Item<RepositoryModel> item) {
final RepositoryModel entry = item.getModelObject();
ProjectRepositoryPanel row = new ProjectRepositoryPanel("repository", getLocalizer(), this, showAdmin, entry, getAccessRestrictions());
item.add(row);
}
};
add(dataView);
}
Aggregations