Browse Source

Fixed collision error on rename repository or user

tags/v0.7.0
James Moger 12 years ago
parent
commit
16038ce2ad

+ 1
- 0
docs/00_index.mkd View File

@@ -40,6 +40,7 @@ Gitblit requires a Java 6 Runtime Environment (JRE) or a Java 6 Development Kit
- added: Gitblit Manager (Java/Swing Application) for remote administration of a Gitblit server.
- fixed: federation protocol timestamps. dates are now serialized to the [iso8601](http://en.wikipedia.org/wiki/ISO_8601) standard.
**This breaks 0.6.0 federation clients/servers.**
- fixed: collision on rename for repositories and users
- fixed: Gitblit can now browse the Linux kernel repository (issue 25)
- fixed: Gitblit now runs on Servlet 3.0 webservers (e.g. Tomcat 7, Jetty 8) (issue 23)
- fixed: Set the RSS content type for Firefox 4 (issue 22)

+ 1
- 0
docs/04_releases.mkd View File

@@ -14,6 +14,7 @@
- added: Gitblit Manager (Java/Swing Application) for remote administration of a Gitblit server.
- fixed: federation protocol timestamps. dates are now serialized to the [iso8601](http://en.wikipedia.org/wiki/ISO_8601) standard.
**This breaks 0.6.0 federation clients/servers.**
- fixed: collision on rename for repositories and users
- fixed: Gitblit can now browse the Linux kernel repository (issue 25)
- fixed: Gitblit now runs on Servlet 3.0 webservers (e.g. Tomcat 7, Jetty 8) (issue 23)
- fixed: Set the RSS content type for Firefox 4 (issue 22)

+ 18
- 0
src/com/gitblit/GitBlit.java View File

@@ -440,6 +440,14 @@ public class GitBlit implements ServletContextListener {
*/
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));
}
}
if (!userService.updateUserModel(username, user)) {
throw new GitBlitException(isCreate ? "Failed to add user!" : "Failed to update user!");
}
@@ -722,6 +730,16 @@ public class GitBlit implements ServletContextListener {
} else {
// rename repository
if (!repositoryName.equalsIgnoreCase(repository.name)) {
if (!repository.name.toLowerCase().endsWith(
org.eclipse.jgit.lib.Constants.DOT_GIT_EXT)) {
repository.name += org.eclipse.jgit.lib.Constants.DOT_GIT_EXT;
}
if (new File(repositoriesFolder, repository.name).exists()) {
throw new GitBlitException(
MessageFormat
.format("Failed to rename ''{0}'' because ''{1}'' already exists.",
repositoryName, repository.name));
}
closeRepository(repositoryName);
File folder = new File(repositoriesFolder, repositoryName);
File destFolder = new File(repositoriesFolder, repository.name);

+ 16
- 2
src/com/gitblit/client/EditRepositoryDialog.java View File

@@ -63,6 +63,8 @@ public class EditRepositoryDialog extends JDialog {
private static final long serialVersionUID = 1L;
private final String repositoryName;
private final RepositoryModel repository;
private boolean isCreate;
@@ -105,6 +107,7 @@ public class EditRepositoryDialog extends JDialog {
public EditRepositoryDialog(RepositoryModel aRepository) {
super();
this.repositoryName = aRepository.name;
this.repository = new RepositoryModel();
this.repositoryNames = new HashSet<String>();
this.isCreate = false;
@@ -114,7 +117,7 @@ public class EditRepositoryDialog extends JDialog {
setTitle(Translation.get("gb.edit") + ": " + aRepository.name);
setIconImage(new ImageIcon(getClass().getResource("/gitblt-favicon.png")).getImage());
}
@Override
protected JRootPane createRootPane() {
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
@@ -175,7 +178,8 @@ public class EditRepositoryDialog extends JDialog {
fieldsPanel
.add(newFieldPanel(Translation.get("gb.showRemoteBranches"), showRemoteBranches));
fieldsPanel.add(newFieldPanel(Translation.get("gb.showReadme"), showReadme));
fieldsPanel.add(newFieldPanel(Translation.get("gb.skipSizeCalculation"), skipSizeCalculation));
fieldsPanel.add(newFieldPanel(Translation.get("gb.skipSizeCalculation"),
skipSizeCalculation));
fieldsPanel.add(newFieldPanel(Translation.get("gb.isFrozen"), isFrozen));
usersPalette = new JPalette<String>();
@@ -292,6 +296,16 @@ public class EditRepositoryDialog extends JDialog {
"Can not create repository ''{0}'' because it already exists.", rname));
return false;
}
} else {
// check rename collision
if (!repositoryName.equalsIgnoreCase(rname)) {
if (repositoryNames.contains(rname.toLowerCase())) {
error(MessageFormat.format(
"Failed to rename ''{0}'' because ''{1}'' already exists.",
repositoryName, rname));
return false;
}
}
}
if (accessRestriction.getSelectedItem() == null) {

+ 13
- 0
src/com/gitblit/client/EditUserDialog.java View File

@@ -55,6 +55,8 @@ public class EditUserDialog extends JDialog {
private static final long serialVersionUID = 1L;
private final String username;
private final UserModel user;
private final ServerSettings settings;
@@ -85,6 +87,7 @@ public class EditUserDialog extends JDialog {
public EditUserDialog(UserModel anUser, ServerSettings settings) {
super();
this.username = anUser.username;
this.user = new UserModel("");
this.settings = settings;
this.usernames = new HashSet<String>();
@@ -194,6 +197,16 @@ public class EditUserDialog extends JDialog {
error(MessageFormat.format("Username ''{0}'' is unavailable.", uname));
return false;
}
} else {
// check rename collision
if (!username.equalsIgnoreCase(uname)) {
if (usernames.contains(uname.toLowerCase())) {
error(MessageFormat.format(
"Failed to rename ''{0}'' because ''{1}'' already exists.", username,
uname));
return false;
}
}
}
int minLength = settings.get(Keys.realm.minPasswordLength).getInteger(5);

+ 2
- 0
src/com/gitblit/client/GitblitPanel.java View File

@@ -656,6 +656,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
List<String> usernames = gitblit.getUsernames();
List<String> members = gitblit.getPermittedUsernames(repository);
dialog.setUsers(repository.owner, usernames, members);
dialog.setRepositories(gitblit.getRepositories());
dialog.setFederationSets(gitblit.getFederationSets(), repository.federationSets);
dialog.setVisible(true);
final RepositoryModel revisedRepository = dialog.getRepository();
@@ -798,6 +799,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
protected void editUser(final UserModel user) {
EditUserDialog dialog = new EditUserDialog(user, gitblit.getSettings());
dialog.setLocationRelativeTo(GitblitPanel.this);
dialog.setUsers(gitblit.getUsers());
dialog.setRepositories(gitblit.getRepositories(), new ArrayList<String>(user.repositories));
dialog.setVisible(true);
final UserModel revisedUser = dialog.getUser();

Loading…
Cancel
Save