@Override
  public void handleException(Exception e) {
    _logger.error(e.getMessage(), e);

    if (!(e instanceof HttpResponseException)) {
      super.handleException(e);

      return;
    }

    HttpResponseException hre = (HttpResponseException) e;

    int statusCode = hre.getStatusCode();

    if (statusCode != HttpStatus.SC_NOT_FOUND) {
      super.handleException(e);

      return;
    }

    SyncAccount syncAccount = SyncAccountService.fetchSyncAccount(getSyncAccountId());

    if (syncAccount.getState() == SyncAccount.STATE_DISCONNECTED) {
      super.handleException(e);

      return;
    }

    SyncFile syncFile = (SyncFile) getParameterValue("syncFile");

    SyncFileService.deleteSyncFile(syncFile, false);
  }
 @Override
 public void onUnhandled(Event event) {
   if (TRACE_LOGGER.isLoggable(Level.FINE)) {
     TRACE_LOGGER.log(
         Level.FINE,
         "Connection.onUnhandled: name["
             + event.getConnection().getHostname()
             + "] : event["
             + event
             + "]");
   }
   super.onUnhandled(event);
 }
  @Override
  public void removeEvent() {
    Map<String, DownloadFileHandler> handlers =
        (Map<String, DownloadFileHandler>) getParameterValue("handlers");

    for (DownloadFileHandler downloadFileHandler : handlers.values()) {
      if (!downloadFileHandler.isEventCancelled()) {
        downloadFileHandler.removeEvent();
      }
    }

    super.removeEvent();
  }
Пример #4
0
  @Override
  public void endHandler(
      String element, HashMap<String, String> attributes, String content, WarningSet warnings)
      throws SAXException {
    super.endHandler(element, attributes, content, warnings);

    if (transition.isFilled()) {
      transition.setAftShoulderThickness(transition.getAftShoulderRadius());
      transition.setForeShoulderThickness(transition.getForeShoulderRadius());
    } else {
      transition.setThickness(thickness);
      transition.setAftShoulderThickness(thickness);
      transition.setForeShoulderThickness(thickness);
    }
  }
 @Override
 public void handleMessage(Message msg) {
   Toast toast = null;
   switch (msg.arg1) {
     case STATUS_STARTED:
       progress = new ProgressDialog(activity);
       progress.setIndeterminate(true);
       progress.setMessage(resources.getString(R.string.interventions_load));
       progress.setCancelable(false);
       progress.show();
       break;
     case STATUS_FINISHED_OK:
       progress.dismiss();
       activity.startActivity(intent);
       break;
     case STATUS_FINISHED_NORESULT:
       toast = Toast.makeText(activity, R.string.interventions_error_noresult, 1000);
       break;
     case STATUS_ERROR_TIMEDOUT:
       toast = Toast.makeText(activity, R.string.error_timedout, 1000);
       break;
     case STATUS_ERROR_CONNREFUSED:
       toast = Toast.makeText(activity, R.string.error_connrefused, 1000);
       break;
     case STATUS_ERROR_JSON:
       toast = Toast.makeText(activity, R.string.error_json, 1000);
       break;
     case STATUS_ERROR_UNKNOWN:
       toast = Toast.makeText(activity, R.string.error_unknown, 1000);
   }
   if (toast != null) {
     progress.dismiss();
     toast.show();
   }
   super.handleMessage(msg);
 }
Пример #6
0
  @Override
  public void closeElement(
      String element, HashMap<String, String> attributes, String content, WarningSet warnings)
      throws SAXException {
    super.closeElement(element, attributes, content, warnings);

    try {
      if ("ShapeCode".equals(element)) {
        transition.setType(RocksimNoseConeCode.fromCode(Integer.parseInt(content)).asOpenRocket());
      }
      if ("Len".equals(element)) {
        transition.setLength(
            Math.max(
                0,
                Double.parseDouble(content) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH));
      }
      if ("FrontDia".equals(element)) {
        transition.setForeRadius(
            Math.max(
                0,
                Double.parseDouble(content) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS));
      }
      if ("RearDia".equals(element)) {
        transition.setAftRadius(
            Math.max(
                0,
                Double.parseDouble(content) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS));
      }
      if ("WallThickness".equals(element)) {
        thickness =
            Math.max(
                0d,
                Double.parseDouble(content) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
      }
      if ("FrontShoulderDia".equals(element)) {
        transition.setForeShoulderRadius(
            Math.max(
                0d,
                Double.parseDouble(content) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS));
      }
      if ("RearShoulderDia".equals(element)) {
        transition.setAftShoulderRadius(
            Math.max(
                0d,
                Double.parseDouble(content) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS));
      }
      if ("FrontShoulderLen".equals(element)) {
        transition.setForeShoulderLength(
            Math.max(
                0d,
                Double.parseDouble(content) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH));
      }
      if ("RearShoulderLen".equals(element)) {
        transition.setAftShoulderLength(
            Math.max(
                0d,
                Double.parseDouble(content) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH));
      }
      if ("ShapeParameter".equals(element)) {
        if (Transition.Shape.POWER.equals(transition.getType())
            || Transition.Shape.HAACK.equals(transition.getType())
            || Transition.Shape.PARABOLIC.equals(transition.getType())) {
          transition.setShapeParameter(Double.parseDouble(content));
        }
      }
      if ("ConstructionType".equals(element)) {
        int typeCode = Integer.parseInt(content);
        if (typeCode == 0) {
          // SOLID
          transition.setFilled(true);
        } else if (typeCode == 1) {
          // HOLLOW
          transition.setFilled(false);
        }
      }
      if ("FinishCode".equals(element)) {
        transition.setFinish(RocksimFinishCode.fromCode(Integer.parseInt(content)).asOpenRocket());
      }
      if ("Material".equals(element)) {
        setMaterialName(content);
      }
    } catch (NumberFormatException nfe) {
      warnings.add(
          "Could not convert "
              + element
              + " value of "
              + content
              + ".  It is expected to be a number.");
    }
  }
 @Override
 public void onConnectionRemoteOpen(Event event) {
   super.onConnectionRemoteOpen(event);
   event.getConnection().open();
 }
 public void go() {
   super.go();
   conn = new Connection(this);
   conn.start();
 }