diff options
-rw-r--r-- | src/com/gitblit/GitBlitException.java | 15 | ||||
-rw-r--r-- | src/com/gitblit/client/GitblitClient.java | 14 | ||||
-rw-r--r-- | src/com/gitblit/client/GitblitManager.java | 7 | ||||
-rw-r--r-- | src/com/gitblit/client/GitblitPanel.java | 1 | ||||
-rw-r--r-- | src/com/gitblit/client/GitblitWorker.java | 6 | ||||
-rw-r--r-- | src/com/gitblit/client/Utils.java | 15 | ||||
-rw-r--r-- | src/com/gitblit/utils/JsonUtils.java | 12 |
7 files changed, 63 insertions, 7 deletions
diff --git a/src/com/gitblit/GitBlitException.java b/src/com/gitblit/GitBlitException.java index 1111463f..360f9f0a 100644 --- a/src/com/gitblit/GitBlitException.java +++ b/src/com/gitblit/GitBlitException.java @@ -56,7 +56,20 @@ public class GitBlitException extends IOException { super(message);
}
}
-
+
+ /**
+ * Exception to indicate that the requested action has been disabled on the
+ * Gitblit server.
+ */
+ public static class NotAllowedException extends GitBlitException {
+
+ private static final long serialVersionUID = 1L;
+
+ public NotAllowedException(String message) {
+ super(message);
+ }
+ }
+
/**
* Exception to indicate that the requested action can not be executed by
* the server because it does not recognize the request type.
diff --git a/src/com/gitblit/client/GitblitClient.java b/src/com/gitblit/client/GitblitClient.java index 761283eb..9f4dd3e6 100644 --- a/src/com/gitblit/client/GitblitClient.java +++ b/src/com/gitblit/client/GitblitClient.java @@ -23,7 +23,9 @@ import java.util.List; import java.util.Map;
import com.gitblit.GitBlitException.ForbiddenException;
+import com.gitblit.GitBlitException.NotAllowedException;
import com.gitblit.GitBlitException.UnauthorizedException;
+import com.gitblit.GitBlitException.UnknownRequestException;
import com.gitblit.Keys;
import com.gitblit.models.FederationModel;
import com.gitblit.models.RepositoryModel;
@@ -78,21 +80,25 @@ public class GitblitClient implements Serializable { try {
refreshUsers();
+ refreshSettings();
allowManagement = true;
} catch (UnauthorizedException e) {
} catch (ForbiddenException e) {
+ } catch (NotAllowedException e) {
+ } catch (UnknownRequestException e) {
} catch (IOException e) {
- System.err.println(e.getMessage());
+ e.printStackTrace();
}
try {
- refreshSettings();
refreshStatus();
allowAdministration = true;
} catch (UnauthorizedException e) {
} catch (ForbiddenException e) {
+ } catch (NotAllowedException e) {
+ } catch (UnknownRequestException e) {
} catch (IOException e) {
- System.err.println(e.getMessage());
+ e.printStackTrace();
}
}
@@ -141,7 +147,7 @@ public class GitblitClient implements Serializable { settings = RpcUtils.getSettings(url, account, password);
return settings;
}
-
+
public ServerStatus refreshStatus() throws IOException {
status = RpcUtils.getStatus(url, account, password);
return status;
diff --git a/src/com/gitblit/client/GitblitManager.java b/src/com/gitblit/client/GitblitManager.java index d902c590..524c213e 100644 --- a/src/com/gitblit/client/GitblitManager.java +++ b/src/com/gitblit/client/GitblitManager.java @@ -65,6 +65,7 @@ import org.eclipse.jgit.util.Base64; import org.eclipse.jgit.util.FS;
import com.gitblit.Constants;
+import com.gitblit.GitBlitException.ForbiddenException;
import com.gitblit.utils.StringUtils;
/**
@@ -277,6 +278,12 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist if (cause instanceof ConnectException) {
JOptionPane.showMessageDialog(GitblitManager.this, cause.getMessage(),
Translation.get("gb.error"), JOptionPane.ERROR_MESSAGE);
+ } else if (cause instanceof ForbiddenException) {
+ JOptionPane
+ .showMessageDialog(
+ GitblitManager.this,
+ "This Gitblit server does not allow RPC Management or Administration",
+ Translation.get("gb.error"), JOptionPane.ERROR_MESSAGE);
} else {
Utils.showException(GitblitManager.this, t);
}
diff --git a/src/com/gitblit/client/GitblitPanel.java b/src/com/gitblit/client/GitblitPanel.java index 1a24f71b..9eb896bc 100644 --- a/src/com/gitblit/client/GitblitPanel.java +++ b/src/com/gitblit/client/GitblitPanel.java @@ -683,6 +683,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener { dialog.setLocationRelativeTo(GitblitPanel.this);
dialog.setUsers(null, gitblit.getUsernames(), null);
dialog.setRepositories(gitblit.getRepositories());
+ dialog.setFederationSets(gitblit.getFederationSets(), null);
dialog.setVisible(true);
final RepositoryModel newRepository = dialog.getRepository();
final List<String> permittedUsers = dialog.getPermittedUsers();
diff --git a/src/com/gitblit/client/GitblitWorker.java b/src/com/gitblit/client/GitblitWorker.java index 45baf03d..5926a77b 100644 --- a/src/com/gitblit/client/GitblitWorker.java +++ b/src/com/gitblit/client/GitblitWorker.java @@ -24,7 +24,9 @@ import javax.swing.SwingWorker; import com.gitblit.Constants.RpcRequest;
import com.gitblit.GitBlitException.ForbiddenException;
+import com.gitblit.GitBlitException.NotAllowedException;
import com.gitblit.GitBlitException.UnauthorizedException;
+import com.gitblit.GitBlitException.UnknownRequestException;
public abstract class GitblitWorker extends SwingWorker<Boolean, Void> {
@@ -59,6 +61,10 @@ public abstract class GitblitWorker extends SwingWorker<Boolean, Void> { Utils.explainForbidden(parent, request);
} else if (t instanceof UnauthorizedException) {
Utils.explainUnauthorized(parent, request);
+ } else if (t instanceof NotAllowedException) {
+ Utils.explainNotAllowed(parent, request);
+ } else if (t instanceof UnknownRequestException) {
+ Utils.explainNotAllowed(parent, request);
} else {
Utils.showException(parent, t);
}
diff --git a/src/com/gitblit/client/Utils.java b/src/com/gitblit/client/Utils.java index ae81e7ff..786eb9f2 100644 --- a/src/com/gitblit/client/Utils.java +++ b/src/com/gitblit/client/Utils.java @@ -48,9 +48,16 @@ public class Utils { return table;
}
+ public static void explainNotAllowed(Component c, RpcRequest request) {
+ String msg = MessageFormat.format("The Gitblit server does not allow the request \"{0}\".",
+ request.name());
+ JOptionPane.showMessageDialog(c, msg, "Not Allowed", JOptionPane.ERROR_MESSAGE);
+ }
+
public static void explainForbidden(Component c, RpcRequest request) {
String msg = MessageFormat.format(
- "The request \"{0}\" has been forbidden by the Gitblit server.", request.name());
+ "The request \"{0}\" has been forbidden for the account by the Gitblit server.",
+ request.name());
JOptionPane.showMessageDialog(c, msg, "Forbidden", JOptionPane.ERROR_MESSAGE);
}
@@ -60,6 +67,12 @@ public class Utils { JOptionPane.showMessageDialog(c, msg, "Unauthorized", JOptionPane.ERROR_MESSAGE);
}
+ public static void explainUnknown(Component c, RpcRequest request) {
+ String msg = MessageFormat.format(
+ "The request \"{0}\" is not recognized by the Gitblit server.", request.name());
+ JOptionPane.showMessageDialog(c, msg, "Unknown Request", JOptionPane.ERROR_MESSAGE);
+ }
+
public static void showException(Component c, Throwable t) {
StringWriter writer = new StringWriter();
t.printStackTrace(new PrintWriter(writer));
diff --git a/src/com/gitblit/utils/JsonUtils.java b/src/com/gitblit/utils/JsonUtils.java index 0c78df95..5b53bf46 100644 --- a/src/com/gitblit/utils/JsonUtils.java +++ b/src/com/gitblit/utils/JsonUtils.java @@ -46,6 +46,7 @@ import javax.net.ssl.X509TrustManager; import org.eclipse.jgit.util.Base64;
import com.gitblit.GitBlitException.ForbiddenException;
+import com.gitblit.GitBlitException.NotAllowedException;
import com.gitblit.GitBlitException.UnauthorizedException;
import com.gitblit.GitBlitException.UnknownRequestException;
import com.gitblit.models.RepositoryModel;
@@ -158,7 +159,7 @@ public class JsonUtils { }
return gson().fromJson(json, type);
}
-
+
/**
* Reads a gson object from the specified url.
*
@@ -216,6 +217,12 @@ public class JsonUtils { } else if (e.getMessage().indexOf("403") > -1) {
// requested url is forbidden by the requesting user
throw new ForbiddenException(url);
+ } else if (e.getMessage().indexOf("405") > -1) {
+ // requested url is not allowed by the server
+ throw new NotAllowedException(url);
+ } else if (e.getMessage().indexOf("501") > -1) {
+ // requested url is not recognized by the server
+ throw new UnknownRequestException(url);
}
throw e;
}
@@ -278,6 +285,9 @@ public class JsonUtils { } else if (e.getMessage().indexOf("403") > -1) {
// requested url is forbidden by the requesting user
throw new ForbiddenException(url);
+ } else if (e.getMessage().indexOf("405") > -1) {
+ // requested url is not allowed by the server
+ throw new NotAllowedException(url);
} else if (e.getMessage().indexOf("501") > -1) {
// requested url is not recognized by the server
throw new UnknownRequestException(url);
|