use of com.gitblit.models.RepositoryModel in project gitblit by gitblit.
the class ITicketService method deleteAll.
/**
* Deletes all tickets in every repository.
*
* @return true if successful
* @since 1.4.0
*/
public boolean deleteAll() {
List<String> repositories = repositoryManager.getRepositoryList();
BitSet bitset = new BitSet(repositories.size());
for (int i = 0; i < repositories.size(); i++) {
String name = repositories.get(i);
RepositoryModel repository = repositoryManager.getRepositoryModel(name);
boolean success = deleteAll(repository);
bitset.set(i, success);
}
boolean success = bitset.cardinality() == repositories.size();
if (success) {
indexer.deleteAll();
resetCaches();
}
return success;
}
use of com.gitblit.models.RepositoryModel in project gitblit by gitblit.
the class ITicketService method updateComment.
/**
* Updates the text of an ticket comment.
*
* @param ticket
* @param commentId
* the id of the comment to revise
* @param updatedBy
* the author of the updated comment
* @param comment
* the revised comment
* @return the revised ticket if the change was successful
* @since 1.4.0
*/
public final TicketModel updateComment(TicketModel ticket, String commentId, String updatedBy, String comment) {
Change revision = new Change(updatedBy);
revision.comment(comment);
revision.comment.id = commentId;
RepositoryModel repository = repositoryManager.getRepositoryModel(ticket.repository);
TicketModel revisedTicket = updateTicket(repository, ticket.number, revision);
return revisedTicket;
}
use of com.gitblit.models.RepositoryModel in project gitblit by gitblit.
the class Issue0259Test method testFile.
/**
* Test the provided users.conf file for expected access permissions.
*
* @throws Exception
*/
@Test
public void testFile() throws Exception {
File realmFile = new File("src/test/resources/issue0259.conf");
ConfigUserService service = new ConfigUserService(realmFile);
RepositoryModel test = repo("test.git", AccessRestrictionType.VIEW);
RepositoryModel projects_test = repo("projects/test.git", AccessRestrictionType.VIEW);
UserModel a = service.getUserModel("a");
UserModel b = service.getUserModel("b");
UserModel c = service.getUserModel("c");
// assert RWD or RW+ for projects/test.git
assertEquals(AccessPermission.DELETE, a.getRepositoryPermission(projects_test).permission);
assertEquals(AccessPermission.DELETE, b.getRepositoryPermission(projects_test).permission);
assertEquals(AccessPermission.REWIND, c.getRepositoryPermission(projects_test).permission);
assertTrue(a.canPush(projects_test));
assertTrue(b.canPush(projects_test));
assertTrue(c.canPush(projects_test));
assertTrue(a.canDeleteRef(projects_test));
assertTrue(b.canDeleteRef(projects_test));
assertTrue(c.canDeleteRef(projects_test));
assertFalse(a.canRewindRef(projects_test));
assertFalse(b.canRewindRef(projects_test));
assertTrue(c.canRewindRef(projects_test));
// assert R for test.git
assertEquals(AccessPermission.CLONE, a.getRepositoryPermission(test).permission);
assertEquals(AccessPermission.CLONE, b.getRepositoryPermission(test).permission);
assertEquals(AccessPermission.REWIND, c.getRepositoryPermission(test).permission);
assertTrue(a.canClone(test));
assertTrue(b.canClone(test));
assertFalse(a.canPush(test));
assertFalse(b.canPush(test));
assertTrue(c.canPush(test));
}
use of com.gitblit.models.RepositoryModel in project gitblit by gitblit.
the class Issue0259Test method testTeam.
/**
* Test a single team that has multiple repository permissions that all match.
* Here defined order IS important. The first permission match wins so it is
* important to define permissions from most-specific match to least-specific
* match.
*
* If the defined permissions are:
* R:.*
* RWD:projects/.*
* then the expected result is R for all repositories because it is first.
*
* But if the defined permissions are:
* RWD:projects/.*
* R:.*
* then the expected result is RWD for projects/test.git and R for test.git
*
* @param reverseOrder
* @throws Exception
*/
private void testTeam(boolean reverseOrder) throws Exception {
RepositoryModel test = repo("test.git", AccessRestrictionType.VIEW);
RepositoryModel projects_test = repo("projects/test.git", AccessRestrictionType.VIEW);
TeamModel t1 = new TeamModel("t1");
if (reverseOrder) {
t1.setRepositoryPermission("projects/.*", AccessPermission.DELETE);
t1.setRepositoryPermission(".*", AccessPermission.CLONE);
} else {
t1.setRepositoryPermission(".*", AccessPermission.CLONE);
t1.setRepositoryPermission("projects/.*", AccessPermission.DELETE);
}
UserModel a = new UserModel("a");
a.teams.add(t1);
// simulate a repository rename
a.setRepositoryPermission("projects/renamed.git", null);
t1.setRepositoryPermission("projects/renamed.git", null);
assertEquals(AccessPermission.CLONE, a.getRepositoryPermission(test).permission);
assertTrue(a.canClone(test));
assertFalse(a.canDeleteRef(test));
assertTrue(a.canClone(projects_test));
if (reverseOrder) {
// RWD permission is found first
assertEquals(AccessPermission.DELETE, a.getRepositoryPermission(projects_test).permission);
assertTrue(a.canDeleteRef(projects_test));
} else {
// R permission is found first
assertEquals(AccessPermission.CLONE, a.getRepositoryPermission(projects_test).permission);
assertFalse(a.canDeleteRef(projects_test));
}
}
use of com.gitblit.models.RepositoryModel in project gitblit by gitblit.
the class Issue0259Test method testTeams.
/**
* Tests multiple teams each with a regex permisson that will match. The
* highest matching permission should be used. Order should be irrelevant.
*
* @param reverseOrder
* @throws Exception
*/
private void testTeams(boolean reverseOrder) throws Exception {
RepositoryModel test = repo("test.git", AccessRestrictionType.VIEW);
RepositoryModel projects_test = repo("projects/test.git", AccessRestrictionType.VIEW);
TeamModel t1 = new TeamModel("t1");
t1.setRepositoryPermission(".*", AccessPermission.CLONE);
TeamModel t2 = new TeamModel("t2");
t2.setRepositoryPermission("projects/.*", AccessPermission.DELETE);
UserModel a = new UserModel("a");
if (reverseOrder) {
a.teams.add(t2);
a.teams.add(t1);
} else {
a.teams.add(t1);
a.teams.add(t2);
}
// simulate a repository rename
a.setRepositoryPermission("projects/renamed.git", null);
t1.setRepositoryPermission("projects/renamed.git", null);
t2.setRepositoryPermission("projects/renamed.git", null);
assertEquals(AccessPermission.CLONE, a.getRepositoryPermission(test).permission);
assertEquals(AccessPermission.DELETE, a.getRepositoryPermission(projects_test).permission);
assertTrue(a.canClone(test));
assertTrue(a.canClone(projects_test));
assertFalse(a.canDeleteRef(test));
assertTrue(a.canDeleteRef(projects_test));
}
Aggregations