本文整理汇总了Java中com.gitblit.models.RepositoryModel.addOwner方法的典型用法代码示例。如果您正苦于以下问题:Java RepositoryModel.addOwner方法的具体用法?Java RepositoryModel.addOwner怎么用?Java RepositoryModel.addOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.gitblit.models.RepositoryModel
的用法示例。
在下文中一共展示了RepositoryModel.addOwner方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EditRepositoryPage
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
public EditRepositoryPage() {
// create constructor
super();
isCreate = true;
RepositoryModel model = new RepositoryModel();
String restriction = GitBlit.getString(Keys.git.defaultAccessRestriction, null);
model.accessRestriction = AccessRestrictionType.fromName(restriction);
String authorization = GitBlit.getString(Keys.git.defaultAuthorizationControl, null);
model.authorizationControl = AuthorizationControl.fromName(authorization);
GitBlitWebSession session = GitBlitWebSession.get();
UserModel user = session.getUser();
if (user != null && user.canCreate() && !user.canAdmin()) {
// personal create permissions, inject personal repository path
model.name = user.getPersonalPath() + "/";
model.projectPath = user.getPersonalPath();
model.addOwner(user.username);
// personal repositories are private by default
model.accessRestriction = AccessRestrictionType.VIEW;
model.authorizationControl = AuthorizationControl.NAMED;
}
setupPage(model);
setStatelessHint(false);
setOutputMarkupId(true);
}
示例2: testOwner
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
@Test
public void testOwner() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
UserModel user = new UserModel("test");
repository.addOwner(user.username);
assertFalse("user SHOULD NOT HAVE a repository permission!", user.hasRepositoryPermission(repository.name));
assertTrue("owner CAN NOT view!", user.canView(repository));
assertTrue("owner CAN NOT clone!", user.canClone(repository));
assertTrue("owner CAN NOT push!", user.canPush(repository));
assertTrue("owner CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("owner CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("owner CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("owner has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
assertTrue("owner CAN NOT fork!", user.canFork(repository));
assertFalse("owner CAN NOT delete!", user.canDelete(repository));
assertTrue("owner CAN NOT edit!", user.canEdit(repository));
}
示例3: testOwnerPersonalRepository
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
@Test
public void testOwnerPersonalRepository() throws Exception {
RepositoryModel repository = new RepositoryModel("~test/myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
UserModel user = new UserModel("test");
repository.addOwner(user.username);
assertFalse("user SHOULD NOT HAVE a repository permission!", user.hasRepositoryPermission(repository.name));
assertTrue("user CAN NOT view!", user.canView(repository));
assertTrue("user CAN NOT clone!", user.canClone(repository));
assertTrue("user CAN NOT push!", user.canPush(repository));
assertTrue("user CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("user CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("user CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("user has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
assertFalse("user CAN fork!", user.canFork(repository));
assertTrue("user CAN NOT delete!", user.canDelete(repository));
assertTrue("user CAN NOT edit!", user.canEdit(repository));
}
示例4: testVisitorPersonalRepository
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
@Test
public void testVisitorPersonalRepository() throws Exception {
RepositoryModel repository = new RepositoryModel("~test/myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
UserModel user = new UserModel("visitor");
repository.addOwner("test");
assertFalse("user HAS a repository permission!", user.hasRepositoryPermission(repository.name));
assertFalse("user CAN view!", user.canView(repository));
assertFalse("user CAN clone!", user.canClone(repository));
assertFalse("user CAN push!", user.canPush(repository));
assertFalse("user CAN create ref!", user.canCreateRef(repository));
assertFalse("user CAN delete ref!", user.canDeleteRef(repository));
assertFalse("user CAN rewind ref!", user.canRewindRef(repository));
assertEquals("user has wrong permission!", AccessPermission.NONE, user.getRepositoryPermission(repository).permission);
assertFalse("user CAN fork!", user.canFork(repository));
assertFalse("user CAN delete!", user.canDelete(repository));
assertFalse("user CAN edit!", user.canEdit(repository));
}
示例5: testProposal
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
@Test
public void testProposal() throws Exception {
// create dummy repository data
Map<String, RepositoryModel> repositories = new HashMap<String, RepositoryModel>();
for (int i = 0; i < 5; i++) {
RepositoryModel model = new RepositoryModel();
model.accessRestriction = AccessRestrictionType.VIEW;
model.description = "cloneable repository " + i;
model.lastChange = new Date();
model.addOwner("adminuser");
model.name = "repo" + i + ".git";
model.size = "5 MB";
model.hasCommits = true;
repositories.put(model.name, model);
}
FederationProposal proposal = new FederationProposal("http://testurl", FederationToken.ALL,
"testtoken", repositories);
// propose federation
assertEquals("proposal refused", FederationUtils.propose(url, proposal),
FederationProposalResult.NO_PROPOSALS);
}
示例6: testOwner
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
@Test
public void testOwner() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
UserModel user = new UserModel("test");
repository.addOwner(user.username);
assertFalse("user SHOULD NOT HAVE a repository permission!", user.hasRepositoryPermission(repository.name));
assertTrue("owner CAN NOT view!", user.canView(repository));
assertTrue("owner CAN NOT clone!", user.canClone(repository));
assertTrue("owner CAN NOT push!", user.canPush(repository));
assertTrue("owner CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("owner CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("owner CAN NOT rewind ref!", user.canRewindRef(repository));
assertTrue("owner CAN NOT fork!", user.canFork(repository));
assertFalse("owner CAN NOT delete!", user.canDelete(repository));
assertTrue("owner CAN NOT edit!", user.canEdit(repository));
}
示例7: testOwnerPersonalRepository
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
@Test
public void testOwnerPersonalRepository() throws Exception {
RepositoryModel repository = new RepositoryModel("~test/myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
UserModel user = new UserModel("test");
repository.addOwner(user.username);
assertFalse("user SHOULD NOT HAVE a repository permission!", user.hasRepositoryPermission(repository.name));
assertTrue("user CAN NOT view!", user.canView(repository));
assertTrue("user CAN NOT clone!", user.canClone(repository));
assertTrue("user CAN NOT push!", user.canPush(repository));
assertTrue("user CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("user CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("user CAN NOT rewind ref!", user.canRewindRef(repository));
assertFalse("user CAN fork!", user.canFork(repository));
assertTrue("user CAN NOT delete!", user.canDelete(repository));
assertTrue("user CAN NOT edit!", user.canEdit(repository));
}
示例8: testVisitorPersonalRepository
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
@Test
public void testVisitorPersonalRepository() throws Exception {
RepositoryModel repository = new RepositoryModel("~test/myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
UserModel user = new UserModel("visitor");
repository.addOwner("test");
assertFalse("user HAS a repository permission!", user.hasRepositoryPermission(repository.name));
assertFalse("user CAN view!", user.canView(repository));
assertFalse("user CAN clone!", user.canClone(repository));
assertFalse("user CAN push!", user.canPush(repository));
assertFalse("user CAN create ref!", user.canCreateRef(repository));
assertFalse("user CAN delete ref!", user.canDeleteRef(repository));
assertFalse("user CAN rewind ref!", user.canRewindRef(repository));
assertFalse("user CAN fork!", user.canFork(repository));
assertFalse("user CAN delete!", user.canDelete(repository));
assertFalse("user CAN edit!", user.canEdit(repository));
}
示例9: 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!");
}
}
示例10: createRepository
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
/**
* An authenticated user with the CREATE role can create a repository on
* push.
*
* @param user
* @param repository
* @param action
* @return the repository model, if it is created, null otherwise
*/
@Override
protected RepositoryModel createRepository(UserModel user, String repository, String action) {
boolean isPush = !StringUtils.isEmpty(action) && gitReceivePack.equals(action);
if (isPush) {
if (user.canCreate(repository)) {
// user is pushing to a new repository
// validate name
if (repository.startsWith("../")) {
logger.error(MessageFormat.format("Illegal relative path in repository name! {0}", repository));
return null;
}
if (repository.contains("/../")) {
logger.error(MessageFormat.format("Illegal relative path in repository name! {0}", repository));
return null;
}
// confirm valid characters in repository name
Character c = StringUtils.findInvalidCharacter(repository);
if (c != null) {
logger.error(MessageFormat.format("Invalid character '{0}' in repository name {1}!", c, repository));
return null;
}
// create repository
RepositoryModel model = new RepositoryModel();
model.name = repository;
model.addOwner(user.username);
model.projectPath = StringUtils.getFirstPathElement(repository);
if (model.isUsersPersonalRepository(user.username)) {
// personal repository, default to private for user
model.authorizationControl = AuthorizationControl.NAMED;
model.accessRestriction = AccessRestrictionType.VIEW;
} else {
// common repository, user default server settings
model.authorizationControl = AuthorizationControl.fromName(GitBlit.getString(Keys.git.defaultAuthorizationControl, ""));
model.accessRestriction = AccessRestrictionType.fromName(GitBlit.getString(Keys.git.defaultAccessRestriction, ""));
}
// create the repository
try {
GitBlit.self().updateRepositoryModel(model.name, model, true);
logger.info(MessageFormat.format("{0} created {1} ON-PUSH", user.username, model.name));
return GitBlit.self().getRepositoryModel(model.name);
} catch (GitBlitException e) {
logger.error(MessageFormat.format("{0} failed to create repository {1} ON-PUSH!", user.username, model.name), e);
}
} else {
logger.warn(MessageFormat.format("{0} is not permitted to create repository {1} ON-PUSH!", user.username, repository));
}
}
// repository could not be created or action was not a push
return null;
}
示例11: testMultipleOwners
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
@Test
public void testMultipleOwners() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
UserModel user = new UserModel("test");
repository.addOwner(user.username);
UserModel user2 = new UserModel("test2");
repository.addOwner(user2.username);
// first owner
assertFalse("user SHOULD NOT HAVE a repository permission!", user.hasRepositoryPermission(repository.name));
assertTrue("owner CAN NOT view!", user.canView(repository));
assertTrue("owner CAN NOT clone!", user.canClone(repository));
assertTrue("owner CAN NOT push!", user.canPush(repository));
assertTrue("owner CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("owner CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("owner CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("owner has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
assertTrue("owner CAN NOT fork!", user.canFork(repository));
assertFalse("owner CAN NOT delete!", user.canDelete(repository));
assertTrue("owner CAN NOT edit!", user.canEdit(repository));
// second owner
assertFalse("user SHOULD NOT HAVE a repository permission!", user2.hasRepositoryPermission(repository.name));
assertTrue("owner CAN NOT view!", user2.canView(repository));
assertTrue("owner CAN NOT clone!", user2.canClone(repository));
assertTrue("owner CAN NOT push!", user2.canPush(repository));
assertTrue("owner CAN NOT create ref!", user2.canCreateRef(repository));
assertTrue("owner CAN NOT delete ref!", user2.canDeleteRef(repository));
assertTrue("owner CAN NOT rewind ref!", user2.canRewindRef(repository));
assertEquals("owner has wrong permission!", AccessPermission.REWIND, user2.getRepositoryPermission(repository).permission);
assertTrue("owner CAN NOT fork!", user2.canFork(repository));
assertFalse("owner CAN NOT delete!", user2.canDelete(repository));
assertTrue("owner CAN NOT edit!", user2.canEdit(repository));
assertTrue(repository.isOwner(user.username));
assertTrue(repository.isOwner(user2.username));
}
示例12: testRepositoryAdministration
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
@Test
public void testRepositoryAdministration() throws IOException {
RepositoryModel model = new RepositoryModel();
model.name = "garbagerepo.git";
model.description = "created by RpcUtils";
model.addOwner("garbage");
model.accessRestriction = AccessRestrictionType.VIEW;
model.authorizationControl = AuthorizationControl.AUTHENTICATED;
// create
assertTrue("Failed to create repository!",
RpcUtils.createRepository(model, url, account, password.toCharArray()));
RepositoryModel retrievedRepository = findRepository(model.name);
assertNotNull("Failed to find " + model.name, retrievedRepository);
assertEquals(AccessRestrictionType.VIEW, retrievedRepository.accessRestriction);
assertEquals(AuthorizationControl.AUTHENTICATED, retrievedRepository.authorizationControl);
// rename and change access restriciton
String originalName = model.name;
model.name = "garbagerepo2.git";
model.accessRestriction = AccessRestrictionType.PUSH;
model.authorizationControl = AuthorizationControl.NAMED;
assertTrue("Failed to update repository!", RpcUtils.updateRepository(originalName, model,
url, account, password.toCharArray()));
retrievedRepository = findRepository(model.name);
assertNotNull("Failed to find " + model.name, retrievedRepository);
assertTrue("Access retriction type is wrong",
AccessRestrictionType.PUSH.equals(retrievedRepository.accessRestriction));
// memberships
UserModel testMember = new UserModel("justadded");
assertTrue(RpcUtils.createUser(testMember, url, account, password.toCharArray()));
List<RegistrantAccessPermission> permissions = RpcUtils.getRepositoryMemberPermissions(retrievedRepository, url, account,
password.toCharArray());
assertEquals("Membership permissions is not empty!", 0, permissions.size());
permissions.add(new RegistrantAccessPermission(testMember.username, AccessPermission.PUSH, PermissionType.EXPLICIT, RegistrantType.USER, null, true));
assertTrue(
"Failed to set member permissions!",
RpcUtils.setRepositoryMemberPermissions(retrievedRepository, permissions, url, account,
password.toCharArray()));
permissions = RpcUtils.getRepositoryMemberPermissions(retrievedRepository, url, account,
password.toCharArray());
boolean foundMember = false;
for (RegistrantAccessPermission permission : permissions) {
if (permission.registrant.equalsIgnoreCase(testMember.username)) {
foundMember = true;
assertEquals(AccessPermission.PUSH, permission.permission);
break;
}
}
assertTrue("Failed to find member!", foundMember);
// delete
assertTrue("Failed to delete " + model.name, RpcUtils.deleteRepository(retrievedRepository,
url, account, password.toCharArray()));
retrievedRepository = findRepository(model.name);
assertNull("Failed to delete " + model.name, retrievedRepository);
for (UserModel u : RpcUtils.getUsers(url, account, password.toCharArray())) {
if (u.username.equals(testMember.username)) {
assertTrue(RpcUtils.deleteUser(u, url, account, password.toCharArray()));
break;
}
}
}
示例13: testMultipleOwners
import com.gitblit.models.RepositoryModel; //导入方法依赖的package包/类
@Test
public void testMultipleOwners() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
UserModel user = new UserModel("test");
repository.addOwner(user.username);
UserModel user2 = new UserModel("test2");
repository.addOwner(user2.username);
// first owner
assertFalse("user SHOULD NOT HAVE a repository permission!", user.hasRepositoryPermission(repository.name));
assertTrue("owner CAN NOT view!", user.canView(repository));
assertTrue("owner CAN NOT clone!", user.canClone(repository));
assertTrue("owner CAN NOT push!", user.canPush(repository));
assertTrue("owner CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("owner CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("owner CAN NOT rewind ref!", user.canRewindRef(repository));
assertTrue("owner CAN NOT fork!", user.canFork(repository));
assertFalse("owner CAN NOT delete!", user.canDelete(repository));
assertTrue("owner CAN NOT edit!", user.canEdit(repository));
// second owner
assertFalse("user SHOULD NOT HAVE a repository permission!", user2.hasRepositoryPermission(repository.name));
assertTrue("owner CAN NOT view!", user2.canView(repository));
assertTrue("owner CAN NOT clone!", user2.canClone(repository));
assertTrue("owner CAN NOT push!", user2.canPush(repository));
assertTrue("owner CAN NOT create ref!", user2.canCreateRef(repository));
assertTrue("owner CAN NOT delete ref!", user2.canDeleteRef(repository));
assertTrue("owner CAN NOT rewind ref!", user2.canRewindRef(repository));
assertTrue("owner CAN NOT fork!", user2.canFork(repository));
assertFalse("owner CAN NOT delete!", user2.canDelete(repository));
assertTrue("owner CAN NOT edit!", user2.canEdit(repository));
assertTrue(repository.isOwner(user.username));
assertTrue(repository.isOwner(user2.username));
}