Exemplo n.º 1
0
  /**
   * Explains a {@link OsmApiException} which was thrown because accessing a protected resource was
   * forbidden (HTTP 403).
   *
   * @param e the exception
   */
  public static void explainAuthorizationFailed(OsmApiException e) {

    Matcher m;
    String msg;
    String url = e.getAccessedUrl();
    Pattern p = Pattern.compile("https?://.*/api/0.6/(node|way|relation)/(\\d+)/(\\d+)");

    // Special case for individual access to redacted versions
    // See http://wiki.openstreetmap.org/wiki/Open_Database_License/Changes_in_the_API
    if (url != null && (m = p.matcher(url)).matches()) {
      String type = m.group(1);
      String id = m.group(2);
      String version = m.group(3);
      // {1} is the translation of "node", "way" or "relation"
      msg =
          tr("Access to redacted version ''{0}'' of {1} {2} is forbidden.", version, tr(type), id);
    } else if (OsmApi.isUsingOAuth()) {
      msg = ExceptionUtil.explainFailedOAuthAuthorisation(e);
    } else {
      msg = ExceptionUtil.explainFailedAuthorisation(e);
    }

    HelpAwareOptionPane.showOptionDialog(
        Main.parent,
        msg,
        tr("Authorisation Failed"),
        JOptionPane.ERROR_MESSAGE,
        ht("/ErrorMessages#AuthorizationFailed"));
  }
Exemplo n.º 2
0
 /**
  * Explains a {@link OsmApiException} which was thrown because a resource wasn't found on the
  * server
  *
  * @param e the exception
  */
 public static void explainNotFound(OsmApiException e) {
   HelpAwareOptionPane.showOptionDialog(
       Main.parent,
       ExceptionUtil.explainNotFound(e),
       tr("Not Found"),
       JOptionPane.ERROR_MESSAGE,
       ht("/ErrorMessages#NotFound"));
 }
Exemplo n.º 3
0
 /**
  * Explains a {@link OsmApiException} which was thrown because of a bad request
  *
  * @param e the exception
  */
 public static void explainBadRequest(OsmApiException e) {
   HelpAwareOptionPane.showOptionDialog(
       Main.parent,
       ExceptionUtil.explainBadRequest(e),
       tr("Bad Request"),
       JOptionPane.ERROR_MESSAGE,
       ht("/ErrorMessages#BadRequest"));
 }
Exemplo n.º 4
0
 /**
  * Explains a {@link OsmApiException} which was thrown because of an internal server error in the
  * OSM API server.
  *
  * @param e the exception
  */
 public static void explainInternalServerError(OsmTransferException e) {
   HelpAwareOptionPane.showOptionDialog(
       Main.parent,
       ExceptionUtil.explainInternalServerError(e),
       tr("Internal Server Error"),
       JOptionPane.ERROR_MESSAGE,
       ht("/ErrorMessages#InternalServerError"));
 }
Exemplo n.º 5
0
 /**
  * Explains a {@link OsmApiException} which was thrown because of a bandwidth limit (HTTP 509)
  *
  * @param e the exception
  */
 public static void explainBandwidthLimitExceeded(OsmApiException e) {
   HelpAwareOptionPane.showOptionDialog(
       Main.parent,
       ExceptionUtil.explainBandwidthLimitExceeded(e),
       tr("Bandwidth Limit Exceeded"),
       JOptionPane.ERROR_MESSAGE,
       ht("/ErrorMessages#BandwidthLimit"));
 }
Exemplo n.º 6
0
 /**
  * Explains a {@link SecurityException} which has caused an {@link OsmTransferException}. This is
  * most likely happening when user tries to access the OSM API from within an applet which wasn't
  * loaded from the API server.
  *
  * @param e the exception
  */
 public static void explainSecurityException(OsmTransferException e) {
   HelpAwareOptionPane.showOptionDialog(
       Main.parent,
       ExceptionUtil.explainSecurityException(e),
       tr("Security exception"),
       JOptionPane.ERROR_MESSAGE,
       ht("/ErrorMessages#SecurityException"));
 }
Exemplo n.º 7
0
 /**
  * Explains an upload error due to a violated precondition, i.e. a HTTP return code 412
  *
  * @param e the exception
  */
 public static void explainPreconditionFailed(OsmApiException e) {
   HelpAwareOptionPane.showOptionDialog(
       Main.parent,
       ExceptionUtil.explainPreconditionFailed(e),
       tr("Precondition violation"),
       JOptionPane.ERROR_MESSAGE,
       ht("/ErrorMessages#OsmApiException"));
 }
Exemplo n.º 8
0
 /**
  * Explains a {@link SocketException} which has caused an {@link OsmTransferException}. This is
  * most likely because there's not connection to the Internet or because the remote server is not
  * reachable.
  *
  * @param e the exception
  */
 public static void explainNestedSocketException(OsmTransferException e) {
   HelpAwareOptionPane.showOptionDialog(
       Main.parent,
       ExceptionUtil.explainNestedSocketException(e),
       tr("Network exception"),
       JOptionPane.ERROR_MESSAGE,
       ht("/ErrorMessages#NestedSocketException"));
 }
Exemplo n.º 9
0
 /**
  * explains the case of an error due to a delete request on an already deleted {@link
  * OsmPrimitive}, i.e. a HTTP response code 410, where we don't know which {@link OsmPrimitive} is
  * causing the error.
  *
  * @param e the exception
  */
 public static void explainGoneForUnknownPrimitive(OsmApiException e) {
   HelpAwareOptionPane.showOptionDialog(
       Main.parent,
       ExceptionUtil.explainGoneForUnknownPrimitive(e),
       tr("Object deleted"),
       JOptionPane.ERROR_MESSAGE,
       ht("/ErrorMessages#GoneForUnknownPrimitive"));
 }
Exemplo n.º 10
0
 /**
  * handles a ChangesetClosedException
  *
  * @param e the exception
  */
 public static void explainChangesetClosedException(ChangesetClosedException e) {
   HelpAwareOptionPane.showOptionDialog(
       Main.parent,
       ExceptionUtil.explainChangesetClosedException(e),
       tr("Error"),
       JOptionPane.ERROR_MESSAGE,
       ht("/Action/Upload#ChangesetClosed"));
 }
Exemplo n.º 11
0
 /**
  * Explains a {@link UnknownHostException} which has caused an {@link OsmTransferException}. This
  * is most likely happening when there is an error in the API URL or when local DNS services are
  * not working.
  *
  * @param e the exception
  */
 public static void explainNestedUnkonwnHostException(OsmTransferException e) {
   HelpAwareOptionPane.showOptionDialog(
       Main.parent,
       ExceptionUtil.explainNestedUnknownHostException(e),
       tr("Unknown host"),
       JOptionPane.ERROR_MESSAGE,
       ht("/ErrorMessages#UnknownHost"));
 }
Exemplo n.º 12
0
 /**
  * handles an exception caught during OSM API initialization
  *
  * @param e the exception
  */
 public static void explainOsmApiInitializationException(OsmApiInitializationException e) {
   HelpAwareOptionPane.showOptionDialog(
       Main.parent,
       ExceptionUtil.explainOsmApiInitializationException(e),
       tr("Error"),
       JOptionPane.ERROR_MESSAGE,
       ht("/ErrorMessages#OsmApiInitializationException"));
 }
Exemplo n.º 13
0
 /**
  * Explains a {@link OsmApiException} which was thrown because accessing a protected resource was
  * forbidden.
  *
  * @param e the exception
  */
 public static void explainMissingOAuthAccessTokenException(MissingOAuthAccessTokenException e) {
   HelpAwareOptionPane.showOptionDialog(
       Main.parent,
       ExceptionUtil.explainMissingOAuthAccessTokenException(e),
       tr("Authentication failed"),
       JOptionPane.ERROR_MESSAGE,
       ht("/ErrorMessages#MissingOAuthAccessToken"));
 }
Exemplo n.º 14
0
 /**
  * Explains a {@link OsmApiException} with a generic error message.
  *
  * @param e the exception
  */
 public static void explainGenericHttpException(OsmApiException e) {
   HelpAwareOptionPane.showOptionDialog(
       Main.parent,
       ExceptionUtil.explainClientTimeout(e),
       tr("Communication with OSM server failed"),
       JOptionPane.ERROR_MESSAGE,
       ht("/ErrorMessages#GenericCommunicationError"));
 }
Exemplo n.º 15
0
 /**
  * Explains a {@link IllegalDataException} which has caused an {@link OsmTransferException}. This
  * is most likely happening when JOSM tries to load data in an unsupported format.
  *
  * @param e the exception
  */
 public static void explainNestedIllegalDataException(OsmTransferException e) {
   HelpAwareOptionPane.showOptionDialog(
       Main.parent,
       ExceptionUtil.explainNestedIllegalDataException(e),
       tr("Illegal Data"),
       JOptionPane.ERROR_MESSAGE,
       ht("/ErrorMessages#IllegalDataException"));
 }
Exemplo n.º 16
0
 /**
  * Explains a {@link OsmApiException} which was thrown because of a client timeout (HTTP 408)
  *
  * @param e the exception
  */
 public static void explainClientTimeout(OsmApiException e) {
   HelpAwareOptionPane.showOptionDialog(
       Main.parent,
       ExceptionUtil.explainClientTimeout(e),
       tr("Client Time Out"),
       JOptionPane.ERROR_MESSAGE,
       ht("/ErrorMessages#ClientTimeOut"));
 }
Exemplo n.º 17
0
  /**
   * Explains a {@link OsmApiException} which was thrown because the authentication at the OSM
   * server failed
   *
   * @param e the exception
   */
  public static void explainAuthenticationFailed(OsmApiException e) {
    String msg;
    if (OsmApi.isUsingOAuth()) {
      msg = ExceptionUtil.explainFailedOAuthAuthentication(e);
    } else {
      msg = ExceptionUtil.explainFailedBasicAuthentication(e);
    }

    HelpAwareOptionPane.showOptionDialog(
        Main.parent,
        msg,
        tr("Authentication Failed"),
        JOptionPane.ERROR_MESSAGE,
        ht("/ErrorMessages#AuthenticationFailed"));
  }