Package de.willuhn.util

Examples of de.willuhn.util.ApplicationException


   * @throws RemoteException
   */
  public static HBCIPassportChipcard createPassport(DDVConfig config) throws ApplicationException, RemoteException
  {
    if (config == null)
      throw new ApplicationException(i18n.tr("Keine Konfiguration ausgew�hlt"));

    Type type = config.getReaderPreset().getType();
   
    if (type.isPCSC())
    {
      String pcscName = config.getPCSCName();
      Logger.info("  pcsc name: " + pcscName);
      if (StringUtils.trimToNull(pcscName) != null)
      {
        HBCIUtils.setParam(PassportParameter.get(type,PassportParameter.NAME),pcscName);
      }
    }
    else
    {
      //////////////////////////////////////////////////////////////////////////
      // JNI-Treiber
      String jni = getJNILib().getAbsolutePath();
      Logger.info("  jni lib: " + jni);
      HBCIUtils.setParam("client.passport.DDV.libname.ddv", jni);
      //
      //////////////////////////////////////////////////////////////////////////

      //////////////////////////////////////////////////////////////////////////
      // CTAPI-Treiber
      String ctapiDriver = config.getCTAPIDriver();
      if (ctapiDriver == null || ctapiDriver.length() == 0)
        throw new ApplicationException(i18n.tr("Kein CTAPI-Treiber in der Kartenleser-Konfiguration angegeben"));

      File ctapi = new File(ctapiDriver);
      if (!ctapi.exists() || !ctapi.isFile() || !ctapi.canRead())
        throw new ApplicationException(i18n.tr("CTAPI-Treiber-Datei \"{0}\" nicht gefunden oder nicht lesbar",ctapiDriver));

      Logger.info("  ctapi driver: " + ctapiDriver);
      HBCIUtils.setParam(PassportParameter.get(type,PassportParameter.CTAPI), ctapiDriver);
      //
      //////////////////////////////////////////////////////////////////////////
View Full Code Here


        file = "libhbci4java-card-freebsd-64.so";
        break;
    }
   
    if (file == null)
      throw new ApplicationException(i18n.tr("Hibiscus unterst�tzt leider keine Chipkartenleser f�r Ihr Betriebssystem"));

    File f = new File(de.willuhn.jameica.hbci.Settings.getLibPath(),file);
    if (!f.exists())
      throw new ApplicationException(i18n.tr("Treiber {0} nicht gefunden",f.getAbsolutePath()));

    if (!f.isFile() || !f.canRead())
      throw new ApplicationException(i18n.tr("Treiber {0} nicht lesbar",f.getAbsolutePath()));

    return f;
  }
View Full Code Here

   * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object)
   */
  public void handleAction(Object context) throws ApplicationException
  {
    if (context == null)
      throw new ApplicationException(i18n.tr("Bitte w�hlen Sie einen oder mehrere Datens�tze aus"));

    if (!(context instanceof Flaggable) && !(context instanceof Flaggable[]))
      throw new ApplicationException(i18n.tr("Bitte w�hlen Sie einen oder mehrere Datens�tze aus"));

    Flaggable[] objects = null;
   
    if (context instanceof Flaggable)
      objects = new Flaggable[]{(Flaggable) context};
    else
      objects = (Flaggable[]) context;

    if (objects.length == 0)
      throw new ApplicationException(i18n.tr("Bitte w�hlen Sie einen oder mehrere Datens�tze aus"));

    try
    {
      objects[0].transactionBegin();
      for (int i=0;i<objects.length;++i)
      {
        int current = objects[i].getFlags();
        boolean have = (current & this.flags) != 0;
        if (this.add && !have)
          objects[i].setFlags(current | this.flags);
        else if (!this.add && have)
          objects[i].setFlags(current ^ this.flags);
       
        this.postProcess(objects[i]);
        objects[i].store();
       
        Application.getMessagingFactory().sendMessage(new ObjectChangedMessage(objects[i]));
      }
      objects[0].transactionCommit();
      Application.getMessagingFactory().sendMessage(new StatusBarMessage(i18n.tr("�nderungen gespeichert"), StatusBarMessage.TYPE_SUCCESS));
    }
    catch (Exception e)
    {
      try {
        objects[0].transactionRollback();
      }
      catch (Exception e1) {
        Logger.error("unable to rollback transaction",e1);
      }
     
      if (e instanceof ApplicationException)
        throw (ApplicationException) e;

      Logger.error("error while setting flags",e);
      throw new ApplicationException(i18n.tr("Fehler beim Speichern der �nderungen"));
    }
  }
View Full Code Here

   */
  public RDHKey importKey(File file) throws ApplicationException, OperationCanceledException
  {
    // Checken, ob die Datei lesbar ist.
    if (file == null)
      throw new ApplicationException(i18n.tr("Bitte w�hlen Sie eine Schl�sseldatei aus"));
   
    if (!file.canRead() || !file.isFile())
      throw new ApplicationException(i18n.tr("Schl�sseldatei nicht lesbar"));

    HBCI plugin           = (HBCI) Application.getPluginLoader().getPlugin(HBCI.class);
    PluginResources res   = plugin.getResources();
   
    // Wir fragen den User, wo er den Schluessel hinhaben will.
    FileDialog dialog = new FileDialog(GUI.getShell(), SWT.SAVE);
    dialog.setText(Application.getI18n().tr("Bitte w�hlen einen Pfad und Dateinamen, an dem der importierte Schl�ssel gespeichert werden soll."));
    dialog.setFileName("hibiscus-" + file.getName());
    dialog.setOverwrite(true);
    dialog.setFilterPath(res.getWorkPath());
    String newFile = dialog.open();
   
    if (newFile == null || newFile.length() == 0)
      throw new ApplicationException(i18n.tr("Keine Datei ausgew�hlt"));
   
    File newKey = new File(newFile);
    if (!newKey.getParentFile().canWrite())
      throw new ApplicationException(i18n.tr("Keine Schreibberechtigung"));

    // BUGZILLA 289
    Settings settings = res.getSettings();
    HBCICallback callback = plugin.getHBCICallback();

    try
    {
      ////////////////////////////////////////////////////////////////////////
      // Erst laden wir den SizRDH-Schluessel
      Logger.info("loading sizrdh key");
      if (callback != null && (callback instanceof HBCICallbackSWT))
        ((HBCICallbackSWT)callback).setCurrentHandle(new PassportHandleImpl());
     
      // Abfrage des Passwortes erzwingen
      settings.setAttribute("hbcicallback.askpassphrase.force",true);
     
      HBCIUtils.setParam("client.passport.SIZRDHFile.filename",file.getAbsolutePath());
      HBCIUtils.setParam("client.passport.SIZRDHFile.libname",getRDHLib());
      HBCIUtils.setParam("client.passport.SIZRDHFile.init","0");
      HBCIPassportInternal source = (HBCIPassportInternal) AbstractHBCIPassport.getInstance("SIZRDHFile");
      ////////////////////////////////////////////////////////////////////////

      ////////////////////////////////////////////////////////////////////////
      // Jetzt erzeugen wir einen im HBCI4Java-Format und kopieren die Daten
      Logger.info("converting into hbci4java format");
      HBCIUtils.setParam("client.passport.default","RDHNew");
      HBCIUtils.setParam("client.passport.RDHNew.filename",newKey.getAbsolutePath());
      HBCIUtils.setParam("client.passport.RDHNew.init","0");
      HBCIPassportInternal target = (HBCIPassportInternal) AbstractHBCIPassport.getInstance("RDHNew");

      target.setCountry(source.getCountry());
      target.setBLZ(source.getBLZ());
      target.setHost(source.getHost());
      target.setPort(source.getPort());
      target.setUserId(source.getUserId());
      target.setCustomerId(source.getCustomerId());
      target.setSysId(source.getSysId());
      target.setSigId(source.getSigId());
      target.setHBCIVersion(source.getHBCIVersion());
      target.setBPD(source.getBPD());
      target.setUPD(source.getUPD());
         
      ((HBCIPassportRDHNew)target).setInstSigKey(source.getInstSigKey());
      ((HBCIPassportRDHNew)target).setInstEncKey(source.getInstEncKey());
      ((HBCIPassportRDHNew)target).setMyPublicSigKey(source.getMyPublicSigKey());
      ((HBCIPassportRDHNew)target).setMyPrivateSigKey(source.getMyPrivateSigKey());
      ((HBCIPassportRDHNew)target).setMyPublicEncKey(source.getMyPublicEncKey());
      ((HBCIPassportRDHNew)target).setMyPrivateEncKey(source.getMyPrivateEncKey());
         
      target.saveChanges();
      target.close();
      source.close();
      ////////////////////////////////////////////////////////////////////////
      RDHKeyImpl key = new RDHKeyImpl(newKey);
      key.setFormat(new HBCI4JavaFormat()); // wir tragen nicht uns selbst ein - da wir den ja ins HBCI4Java-Format konvertiert haben
      return key;
    }
    catch (ApplicationException ae)
    {
      throw ae;
    }
    catch (OperationCanceledException oce)
    {
      throw oce;
    }
    catch (Exception e)
    {
      OperationCanceledException oce = (OperationCanceledException) HBCIProperties.getCause(e,OperationCanceledException.class);
      if (oce != null)
        throw oce;
       
      ApplicationException ae = (ApplicationException) HBCIProperties.getCause(e,ApplicationException.class);
      if (ae != null)
        throw ae;

      Logger.error("unable to import key " + file.getAbsolutePath(),e);
      throw new ApplicationException(i18n.tr("Schl�sseldatei kann nicht importiert werden: {0}",e.getMessage()));
    }
    finally
    {
      settings.setAttribute("hbcicallback.askpassphrase.force",false);
      if (callback != null && (callback instanceof HBCICallbackSWT))
View Full Code Here

   */
  public RDHKey importKey(File file) throws ApplicationException, OperationCanceledException
  {
    // Checken, ob die Datei lesbar ist.
    if (file == null)
      throw new ApplicationException(i18n.tr("Bitte w�hlen Sie eine Schl�sseldatei aus"));
   
    if (!file.canRead() || !file.isFile())
      throw new ApplicationException(i18n.tr("Schl�sseldatei nicht lesbar"));
   
    // Das ist ein Hibiscus-Schluessel. Wir lassen den Schluessel gleich dort, wo er ist
    try
    {
      RDHKeyImpl key = new RDHKeyImpl(file);
      key.setFormat(this);
      return key;
    }
    catch (RemoteException re)
    {
      Logger.error("unable to import key " + file.getAbsolutePath(),re);
      throw new ApplicationException(i18n.tr("Schl�sseldatei kann nicht importiert werden: {0}",re.getMessage()));
    }
  }
View Full Code Here

    {
      OperationCanceledException oce = (OperationCanceledException) HBCIProperties.getCause(e,OperationCanceledException.class);
      if (oce != null)
        throw oce;
       
      ApplicationException ae = (ApplicationException) HBCIProperties.getCause(e,ApplicationException.class);
      if (ae != null)
        throw ae;

      Logger.error("unable to load key",e);
      throw new ApplicationException(i18n.tr("Fehler beim Laden des Schl�ssels: {0}",e.getMessage()));
    }
    finally
    {
      if (callback != null && (callback instanceof HBCICallbackSWT))
        ((HBCICallbackSWT)callback).setCurrentHandle(null);
View Full Code Here

              action.handleAction(getTransfer());
            }
            catch (RemoteException e)
            {
              Logger.error("unable to load sammelueberweisung",e);
              throw new ApplicationException(i18n.tr("Fehler beim Laden des Sammel-Auftrages"));
            }
          }
        }
      },"text-x-generic.png");
    }
View Full Code Here

   * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object)
   */
  public void handleAction(Object context) throws ApplicationException
  {
    if (!(context instanceof SepaDauerauftrag))
      throw new ApplicationException(i18n.tr("Kein SEPA-Dauerauftrag ausgew�hlt"));

    final SepaDauerauftrag da = (SepaDauerauftrag) context;

    try
    {
      final CheckboxInput check = new CheckboxInput(true);
      YesNoDialog d = new YesNoDialog(YesNoDialog.POSITION_CENTER)
      {
        // BUGZILLA #999
        protected void extend(Container container) throws Exception
        {
          // Nur bei aktiven Dauerauftraegen anzeigen
          if (da.isActive()) {
            final LabelInput warn = new LabelInput("");
            warn.setColor(Color.COMMENT);
            check.addListener(new Listener() {
              public void handleEvent(Event event)
              {
                // Warnhinweis anzeigen, dass der Auftrag nur lokal geloescht wird
                Boolean b = (Boolean) check.getValue();
                if (b.booleanValue())
                  warn.setValue("");
                else
                  warn.setValue(i18n.tr("Auftrag wird nur lokal gel�scht, bei der Bank bleibt er erhalten."));
              }
            });
            container.addCheckbox(check,i18n.tr("Auftrag auch bei der Bank l�schen."));
            container.addLabelPair("",warn);
          }
          super.extend(container);
        }
      };
      d.setTitle(i18n.tr("SEPA-Dauerauftrag l�schen"));
      d.setText(i18n.tr("Wollen Sie diesen Dauerauftrag wirklich l�schen?"));
      d.setSize(350,SWT.DEFAULT);

      Boolean choice = (Boolean) d.open();
      if (!choice.booleanValue())
        return;

      // Nur bei der Bank loeschen, wenn er aktiv ist und der User das will
      // BUGZILLA #15
      if (da.isActive() && (Boolean) check.getValue())
      {

        BaseDauerauftragDeleteDialog d2 = new BaseDauerauftragDeleteDialog(BaseDauerauftragDeleteDialog.POSITION_CENTER);
        Date date = (Date) d2.open();
       
        Konto konto = da.getKonto();
        Class<SynchronizeJobSepaDauerauftragDelete> type = SynchronizeJobSepaDauerauftragDelete.class;

        BeanService bs = Application.getBootLoader().getBootable(BeanService.class);
        SynchronizeEngine engine   = bs.get(SynchronizeEngine.class);
        SynchronizeBackend backend = engine.getBackend(type,konto);
        SynchronizeJob job         = backend.create(type,konto);
       
        job.setContext(SynchronizeJob.CTX_ENTITY,da);
        job.setContext(SynchronizeJobSepaDauerauftragDelete.CTX_DATE,date);
       
        // Das Loeschen der Entity uebernimmt der HBCISepaDauerauftragDeleteJob selbst in "markExecuted"
        backend.execute(Arrays.asList(job));
      }
      else
      {
        // nur lokal loeschen
        da.delete();
        Application.getMessagingFactory().sendMessage(new StatusBarMessage(i18n.tr("SEPA-Dauerauftrag lokal gel�scht."),StatusBarMessage.TYPE_SUCCESS));
      }
    }
    catch (OperationCanceledException oce)
    {
      Logger.info("operation cancelled");
      return;
    }
    catch (ApplicationException ae)
    {
      throw ae;
    }
    catch (Exception e)
    {
      Logger.error("error while deleting",e);
      throw new ApplicationException(i18n.tr("Fehler beim L�schen des Auftrages: {0}",e.getMessage()));
    }
  }
View Full Code Here

   * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object)
   */
  public void handleAction(Object context) throws ApplicationException
  {
    if (!(context instanceof AuslandsUeberweisung) && !(context instanceof AuslandsUeberweisung[]))
      throw new ApplicationException(i18n.tr("Bitte w�hlen Sie einen oder mehrere Auftr�ge aus"));

    AuslandsUeberweisung[] source = null;
   
    if (context instanceof AuslandsUeberweisung)
      source = new AuslandsUeberweisung[]{(AuslandsUeberweisung) context};
    else
      source = (AuslandsUeberweisung[]) context;
   
    if (source.length == 0)
      throw new ApplicationException(i18n.tr("Bitte w�hlen Sie einen oder mehrere Auftr�ge aus"));

   
    SepaSammelUeberweisung tx = null;
   
    try
    {
      HBCIDBService service = Settings.getDBService();
      Map<String,SepaSammelUeberweisung> map = new HashMap<String,SepaSammelUeberweisung>();
      boolean inDb = false;
      ////////////////////////////////////////
      // 1. Iterieren ueber die Auftraege, um herauszufinden, wieviele Sammel-Auftraege es werden
      for (AuslandsUeberweisung l:source)
      {
        inDb |= !l.isNewObject();
        String key = this.createKey(l);
        SepaSammelUeberweisung s = map.get(key);
        if (s == null)
        {
          s = (SepaSammelUeberweisung) service.createObject(SepaSammelUeberweisung.class,null);
          s.setKonto(l.getKonto());
          s.setBezeichnung(i18n.tr("SEPA-Sammel�berweisung vom {0}",HBCI.LONGDATEFORMAT.format(new Date())));
          map.put(key,s);
        }
      }
     
      // Abfrage anzeigen, ob die Einzelauftraege geloescht werden sollen
      // a) wenn mindestens einer in der DB existierte
      // b) oder mehr als ein Sammelauftrag entsteht.
      boolean delete = false;
      int count = map.size();
      if (count > 1 || inDb)
      {
        SepaUeberweisungMergeDialog dialog = new SepaUeberweisungMergeDialog(SepaUeberweisungMergeDialog.POSITION_CENTER,count,inDb);
        Object o = dialog.open();
        if (o != null)
          delete = ((Boolean)o).booleanValue();
      }
     
      // OK, wir duerfen weiter machen. Erstmal die Sammelauftraege anlegen
      Iterator<SepaSammelUeberweisung> list = map.values().iterator();
      while (list.hasNext())
      {
        SepaSammelUeberweisung s = list.next();
       
        if (tx == null)
        {
          tx = s;
          tx.transactionBegin();
        }
       
        s.store();
        Application.getMessagingFactory().sendMessage(new ImportMessage(s));
      }
     
      // jetzt iterieren wir nochmal ueber die Einzelauftraege und ordnen sie den
      // Sammelauftraegen zu
      for (AuslandsUeberweisung l:source)
      {
        String key = this.createKey(l);
        SepaSammelUeberweisung s = map.get(key);
       
       
        if (s == null) // WTF?
        {
          Logger.error("unable to find sepa transfer for key " + key);
          continue;
        }
       
        SepaSammelUeberweisungBuchung b = s.createBuchung();
        b.setBetrag(l.getBetrag());
        b.setEndtoEndId(l.getEndtoEndId());
        b.setGegenkontoBLZ(l.getGegenkontoBLZ());
        b.setGegenkontoName(l.getGegenkontoName());
        b.setGegenkontoNummer(l.getGegenkontoNummer());
        b.setZweck(l.getZweck());
        b.store();
        Application.getMessagingFactory().sendMessage(new ImportMessage(b));
        Application.getMessagingFactory().sendMessage(new ObjectChangedMessage(s));
       
        if (delete && !l.isNewObject())
        {
          l.delete();
          Application.getMessagingFactory().sendMessage(new ObjectDeletedMessage(l));
        }
      }
     
      tx.transactionCommit();

      if (count > 1)
        Application.getMessagingFactory().sendMessage(new StatusBarMessage(i18n.tr("{0} Sammelauftr�ge erzeugt",String.valueOf(count)), StatusBarMessage.TYPE_SUCCESS));
      else
        Application.getMessagingFactory().sendMessage(new StatusBarMessage(i18n.tr("Sammelauftrag erzeugt"), StatusBarMessage.TYPE_SUCCESS));
    }
    catch (Exception e)
    {
      if (tx != null)
      {
        try
        {
          tx.transactionRollback();
        }
        catch (Exception e2)
        {
          Logger.error("unable to rollback transaction",e);
        }
      }
     
      if (e instanceof OperationCanceledException)
        throw (OperationCanceledException) e;
     
      if (e instanceof ApplicationException)
        throw (ApplicationException) e;
     
      Logger.error("error while merging jobs",e);
      throw new ApplicationException(i18n.tr("Zusammenfassen der �berweisungen fehlgeschlagen: {0}",e.getMessage()));
    }
  }
View Full Code Here

   */
  public RDHKey importKey(File file) throws ApplicationException, OperationCanceledException
  {
    // Checken, ob die Datei lesbar ist.
    if (file == null)
      throw new ApplicationException(i18n.tr("Bitte w�hlen Sie eine Schl�sseldatei aus"));
   
    if (!file.canRead() || !file.isFile())
      throw new ApplicationException(i18n.tr("Schl�sseldatei nicht lesbar"));
   
    // Das ist ein Hibiscus-Schluessel. Wir lassen den Schluessel gleich dort, wo er ist
    try
    {
      RDHKeyImpl key = new RDHKeyImpl(file);
      key.setFormat(this);
      return key;
    }
    catch (RemoteException re)
    {
      Logger.error("unable to import key " + file.getAbsolutePath(),re);
      throw new ApplicationException(i18n.tr("Schl�sseldatei kann nicht importiert werden: {0}",re.getMessage()));
    }
  }
View Full Code Here

TOP

Related Classes of de.willuhn.util.ApplicationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.