本文整理汇总了Java中com.gitblit.models.RepositoryModel.isOwner方法的典型用法代码示例。如果您正苦于以下问题:Java RepositoryModel.isOwner方法的具体用法?Java RepositoryModel.isOwner怎么用?Java RepositoryModel.isOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.gitblit.models.RepositoryModel
的用法示例。
在下文中一共展示了RepositoryModel.isOwner方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateUserModel
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
/**
* Adds/updates a complete user object keyed by username. This method allows
* for renaming a user.
*
* @see IUserService.updateUserModel(String, UserModel)
* @param username
* @param user
* @param isCreate
* @throws GitBlitException
*/
public void updateUserModel(String username, UserModel user, boolean isCreate)
throws GitBlitException {
if (!username.equalsIgnoreCase(user.username)) {
if (userService.getUserModel(user.username) != null) {
throw new GitBlitException(MessageFormat.format(
"Failed to rename ''{0}'' because ''{1}'' already exists.", username,
user.username));
}
// rename repositories and owner fields for all repositories
for (RepositoryModel model : getRepositoryModels(user)) {
if (model.isUsersPersonalRepository(username)) {
// personal repository
model.addOwner(user.username);
String oldRepositoryName = model.name;
model.name = "~" + user.username + model.name.substring(model.projectPath.length());
model.projectPath = "~" + user.username;
updateRepositoryModel(oldRepositoryName, model, false);
} else if (model.isOwner(username)) {
// common/shared repo
model.addOwner(user.username);
updateRepositoryModel(model.name, model, false);
}
}
}
if (!userService.updateUserModel(username, user)) {
throw new GitBlitException(isCreate ? "Failed to add user!" : "Failed to update user!");
}
}
示例2: checkPermissions
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
/**
* Unfortunately must repeat part of AuthorizaitonStrategy here because that
* mechanism does not take PageParameters into consideration, only page
* instantiation.
*
* Repository Owners should be able to edit their repository.
*/
private void checkPermissions(RepositoryModel model) {
boolean authenticateAdmin = GitBlit.getBoolean(Keys.web.authenticateAdminPages, true);
boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, true);
GitBlitWebSession session = GitBlitWebSession.get();
UserModel user = session.getUser();
if (allowAdmin) {
if (authenticateAdmin) {
if (user == null) {
// No Login Available
error(getString("gb.errorAdminLoginRequired"), true);
}
if (isCreate) {
// Create Repository
if (!user.canCreate() && !user.canAdmin()) {
// Only administrators or permitted users may create
error(getString("gb.errorOnlyAdminMayCreateRepository"), true);
}
} else {
// Edit Repository
if (user.canAdmin()) {
// Admins can edit everything
isAdmin = true;
return;
} else {
if (!model.isOwner(user.username)) {
// User is not an Admin nor Owner
error(getString("gb.errorOnlyAdminOrOwnerMayEditRepository"), true);
}
}
}
}
} else {
// No Administration Permitted
error(getString("gb.errorAdministrationDisabled"), true);
}
}
示例3: getAccessRestrictedRepositoryList
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
protected List<String> getAccessRestrictedRepositoryList(boolean includeWildcards, UserModel user) {
// build list of access-restricted projects
String lastProject = null;
List<String> repos = new ArrayList<String>();
if (includeWildcards) {
// all repositories
repos.add(".*");
// all repositories excluding personal repositories
repos.add("[^~].*");
}
for (String repo : GitBlit.self().getRepositoryList()) {
RepositoryModel repositoryModel = GitBlit.self().getRepositoryModel(repo);
if (repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE)
&& repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED)) {
if (user != null &&
(repositoryModel.isOwner(user.username) || repositoryModel.isUsersPersonalRepository(user.username))) {
// exclude Owner or personal repositories
continue;
}
if (includeWildcards) {
if (lastProject == null || !lastProject.equalsIgnoreCase(repositoryModel.projectPath)) {
lastProject = repositoryModel.projectPath.toLowerCase();
if (!StringUtils.isEmpty(repositoryModel.projectPath)) {
// regex for all repositories within a project
repos.add(repositoryModel.projectPath + "/.*");
}
}
}
repos.add(repo.toLowerCase());
}
}
return repos;
}
示例4: isOwner
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
public boolean isOwner(RepositoryModel model) {
return model.isOwner(account);
}
示例5: registerPages
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
private Map<String, PageRegistration> registerPages() {
PageParameters params = null;
if (!StringUtils.isEmpty(repositoryName)) {
params = WicketUtils.newRepositoryParameter(repositoryName);
}
Map<String, PageRegistration> pages = new LinkedHashMap<String, PageRegistration>();
Repository r = getRepository();
RepositoryModel model = getRepositoryModel();
// standard links
if (PushLogUtils.getPushLogBranch(r) == null) {
pages.put("summary", new PageRegistration("gb.summary", SummaryPage.class, params));
} else {
pages.put("summary", new PageRegistration("gb.summary", SummaryPage.class, params));
// pages.put("overview", new PageRegistration("gb.overview", OverviewPage.class, params));
pages.put("pushes", new PageRegistration("gb.pushes", PushesPage.class, params));
}
pages.put("commits", new PageRegistration("gb.commits", LogPage.class, params));
pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params));
pages.put("compare", new PageRegistration("gb.compare", ComparePage.class, params, true));
if (GitBlit.getBoolean(Keys.web.allowForking, true)) {
pages.put("forks", new PageRegistration("gb.forks", ForksPage.class, params, true));
}
// conditional links
// per-repository extra page links
if (model.useTickets && TicgitUtils.getTicketsBranch(r) != null) {
pages.put("tickets", new PageRegistration("gb.tickets", TicketsPage.class, params, true));
}
if (model.showReadme || model.useDocs) {
pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params, true));
}
if (JGitUtils.getPagesBranch(r) != null) {
OtherPageLink pagesLink = new OtherPageLink("gb.pages", PagesServlet.asLink(
getRequest().getRelativePathPrefixToContextRoot(), repositoryName, null), true);
pages.put("pages", pagesLink);
}
// Conditionally add edit link
showAdmin = false;
if (GitBlit.getBoolean(Keys.web.authenticateAdminPages, true)) {
boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, false);
showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin();
} else {
showAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, false);
}
isOwner = GitBlitWebSession.get().isLoggedIn()
&& (model.isOwner(GitBlitWebSession.get()
.getUsername()));
if (showAdmin || isOwner) {
pages.put("edit", new PageRegistration("gb.edit", EditRepositoryPage.class, params));
}
return pages;
}
示例6: registerPages
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
private Map<String, PageRegistration> registerPages() {
PageParameters params = null;
if (!StringUtils.isEmpty(repositoryName)) {
params = WicketUtils.newRepositoryParameter(repositoryName);
}
Map<String, PageRegistration> pages = new LinkedHashMap<String, PageRegistration>();
// standard links
pages.put("repositories", new PageRegistration("gb.repositories", RepositoriesPage.class));
pages.put("summary", new PageRegistration("gb.summary", SummaryPage.class, params));
pages.put("log", new PageRegistration("gb.log", LogPage.class, params));
pages.put("branches", new PageRegistration("gb.branches", BranchesPage.class, params));
pages.put("tags", new PageRegistration("gb.tags", TagsPage.class, params));
pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params));
if (GitBlit.getBoolean(Keys.web.allowForking, true)) {
pages.put("forks", new PageRegistration("gb.forks", ForksPage.class, params));
}
// conditional links
Repository r = getRepository();
RepositoryModel model = getRepositoryModel();
// per-repository extra page links
if (model.useTickets && TicgitUtils.getTicketsBranch(r) != null) {
pages.put("tickets", new PageRegistration("gb.tickets", TicketsPage.class, params));
}
if (model.useDocs) {
pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params));
}
if (JGitUtils.getPagesBranch(r) != null) {
OtherPageLink pagesLink = new OtherPageLink("gb.pages", PagesServlet.asLink(
getRequest().getRelativePathPrefixToContextRoot(), repositoryName, null));
pages.put("pages", pagesLink);
}
// Conditionally add edit link
showAdmin = false;
if (GitBlit.getBoolean(Keys.web.authenticateAdminPages, true)) {
boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, false);
showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin();
} else {
showAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, false);
}
isOwner = GitBlitWebSession.get().isLoggedIn()
&& (model.isOwner(GitBlitWebSession.get()
.getUsername()));
if (showAdmin || isOwner) {
pages.put("edit", new PageRegistration("gb.edit", EditRepositoryPage.class, params));
}
return pages;
}