super(message);\r
}\r
}\r
- \r
+\r
+ /**\r
+ * Exception to indicate that the requested action has been disabled on the\r
+ * Gitblit server.\r
+ */\r
+ public static class NotAllowedException extends GitBlitException {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ public NotAllowedException(String message) {\r
+ super(message);\r
+ }\r
+ }\r
+\r
/**\r
* Exception to indicate that the requested action can not be executed by\r
* the server because it does not recognize the request type.\r
import java.util.Map;\r
\r
import com.gitblit.GitBlitException.ForbiddenException;\r
+import com.gitblit.GitBlitException.NotAllowedException;\r
import com.gitblit.GitBlitException.UnauthorizedException;\r
+import com.gitblit.GitBlitException.UnknownRequestException;\r
import com.gitblit.Keys;\r
import com.gitblit.models.FederationModel;\r
import com.gitblit.models.RepositoryModel;\r
\r
try {\r
refreshUsers();\r
+ refreshSettings();\r
allowManagement = true;\r
} catch (UnauthorizedException e) {\r
} catch (ForbiddenException e) {\r
+ } catch (NotAllowedException e) {\r
+ } catch (UnknownRequestException e) {\r
} catch (IOException e) {\r
- System.err.println(e.getMessage());\r
+ e.printStackTrace();\r
}\r
\r
try {\r
- refreshSettings();\r
refreshStatus();\r
allowAdministration = true;\r
} catch (UnauthorizedException e) {\r
} catch (ForbiddenException e) {\r
+ } catch (NotAllowedException e) {\r
+ } catch (UnknownRequestException e) {\r
} catch (IOException e) {\r
- System.err.println(e.getMessage());\r
+ e.printStackTrace();\r
}\r
\r
}\r
settings = RpcUtils.getSettings(url, account, password);\r
return settings;\r
}\r
- \r
+\r
public ServerStatus refreshStatus() throws IOException {\r
status = RpcUtils.getStatus(url, account, password);\r
return status;\r
import org.eclipse.jgit.util.FS;\r
\r
import com.gitblit.Constants;\r
+import com.gitblit.GitBlitException.ForbiddenException;\r
import com.gitblit.utils.StringUtils;\r
\r
/**\r
if (cause instanceof ConnectException) {\r
JOptionPane.showMessageDialog(GitblitManager.this, cause.getMessage(),\r
Translation.get("gb.error"), JOptionPane.ERROR_MESSAGE);\r
+ } else if (cause instanceof ForbiddenException) {\r
+ JOptionPane\r
+ .showMessageDialog(\r
+ GitblitManager.this,\r
+ "This Gitblit server does not allow RPC Management or Administration",\r
+ Translation.get("gb.error"), JOptionPane.ERROR_MESSAGE);\r
} else {\r
Utils.showException(GitblitManager.this, t);\r
}\r
dialog.setLocationRelativeTo(GitblitPanel.this);\r
dialog.setUsers(null, gitblit.getUsernames(), null);\r
dialog.setRepositories(gitblit.getRepositories());\r
+ dialog.setFederationSets(gitblit.getFederationSets(), null);\r
dialog.setVisible(true);\r
final RepositoryModel newRepository = dialog.getRepository();\r
final List<String> permittedUsers = dialog.getPermittedUsers();\r
\r
import com.gitblit.Constants.RpcRequest;\r
import com.gitblit.GitBlitException.ForbiddenException;\r
+import com.gitblit.GitBlitException.NotAllowedException;\r
import com.gitblit.GitBlitException.UnauthorizedException;\r
+import com.gitblit.GitBlitException.UnknownRequestException;\r
\r
public abstract class GitblitWorker extends SwingWorker<Boolean, Void> {\r
\r
Utils.explainForbidden(parent, request);\r
} else if (t instanceof UnauthorizedException) {\r
Utils.explainUnauthorized(parent, request);\r
+ } else if (t instanceof NotAllowedException) {\r
+ Utils.explainNotAllowed(parent, request);\r
+ } else if (t instanceof UnknownRequestException) {\r
+ Utils.explainNotAllowed(parent, request);\r
} else {\r
Utils.showException(parent, t);\r
}\r
return table;\r
}\r
\r
+ public static void explainNotAllowed(Component c, RpcRequest request) {\r
+ String msg = MessageFormat.format("The Gitblit server does not allow the request \"{0}\".",\r
+ request.name());\r
+ JOptionPane.showMessageDialog(c, msg, "Not Allowed", JOptionPane.ERROR_MESSAGE);\r
+ }\r
+\r
public static void explainForbidden(Component c, RpcRequest request) {\r
String msg = MessageFormat.format(\r
- "The request \"{0}\" has been forbidden by the Gitblit server.", request.name());\r
+ "The request \"{0}\" has been forbidden for the account by the Gitblit server.",\r
+ request.name());\r
JOptionPane.showMessageDialog(c, msg, "Forbidden", JOptionPane.ERROR_MESSAGE);\r
}\r
\r
JOptionPane.showMessageDialog(c, msg, "Unauthorized", JOptionPane.ERROR_MESSAGE);\r
}\r
\r
+ public static void explainUnknown(Component c, RpcRequest request) {\r
+ String msg = MessageFormat.format(\r
+ "The request \"{0}\" is not recognized by the Gitblit server.", request.name());\r
+ JOptionPane.showMessageDialog(c, msg, "Unknown Request", JOptionPane.ERROR_MESSAGE);\r
+ }\r
+\r
public static void showException(Component c, Throwable t) {\r
StringWriter writer = new StringWriter();\r
t.printStackTrace(new PrintWriter(writer));\r
import org.eclipse.jgit.util.Base64;\r
\r
import com.gitblit.GitBlitException.ForbiddenException;\r
+import com.gitblit.GitBlitException.NotAllowedException;\r
import com.gitblit.GitBlitException.UnauthorizedException;\r
import com.gitblit.GitBlitException.UnknownRequestException;\r
import com.gitblit.models.RepositoryModel;\r
}\r
return gson().fromJson(json, type);\r
}\r
- \r
+\r
/**\r
* Reads a gson object from the specified url.\r
* \r
} else if (e.getMessage().indexOf("403") > -1) {\r
// requested url is forbidden by the requesting user\r
throw new ForbiddenException(url);\r
+ } else if (e.getMessage().indexOf("405") > -1) {\r
+ // requested url is not allowed by the server\r
+ throw new NotAllowedException(url);\r
+ } else if (e.getMessage().indexOf("501") > -1) {\r
+ // requested url is not recognized by the server\r
+ throw new UnknownRequestException(url);\r
}\r
throw e;\r
}\r
} else if (e.getMessage().indexOf("403") > -1) {\r
// requested url is forbidden by the requesting user\r
throw new ForbiddenException(url);\r
+ } else if (e.getMessage().indexOf("405") > -1) {\r
+ // requested url is not allowed by the server\r
+ throw new NotAllowedException(url);\r
} else if (e.getMessage().indexOf("501") > -1) {\r
// requested url is not recognized by the server\r
throw new UnknownRequestException(url);\r