Package es.ipsa.atril.sec.authentication

Examples of es.ipsa.atril.sec.authentication.AtrilSession


     * @return Número de créditos libres
     */
    public String getCreditsleft() {
        try {
            connect();
            AtrilSession oSes = getSession();
            if(oSes!=null){
            Dms oDms = oSes.getDms();
            CustomerAccount cacc = new CustomerAccount(oDms, getSessionAttribute("customer_account_docid"));
            disconnect();
            return cacc.getCreditsLeft().toString().substring(0, cacc.getCreditsLeft().toString().indexOf("."));
            }
        } catch (StorageException ex) {
View Full Code Here


     * @return Número de créditos usados
     */
    public String getCreditsused() {
        try {
            connect();
            AtrilSession oSes = getSession();
            if(oSes!=null){
            Dms oDms = oSes.getDms();
            CustomerAccount cacc = new CustomerAccount(oDms, getSessionAttribute("customer_account_docid"));
            disconnect();
            return cacc.getCreditsUsed().toString().substring(0, cacc.getCreditsUsed().toString().indexOf("."));
            }
        } catch (StorageException ex) {
View Full Code Here

      return a;
   

  public static Collection<AccountingAccountDefault> list() {
    if (oCache==null) {
      AtrilSession oSes = DAO.getAdminSession("AccountingAccountsDefaults");
      oCache = new ArrayList<AccountingAccountDefault>();
      for (Document d : top(oSes).getDocument().children())
        oCache.add(new AccountingAccountDefault(d));
      oSes.disconnect();
      oSes.close();
    }
    return oCache;
  }
View Full Code Here

  public CaptureService getCaptureService() {
    return null;
  }

  public Collection<TaxPayer> getTaxPayers() throws ElementNotFoundException, NotEnoughRightsException, DmsException, InstantiationException, IllegalAccessException {
    AtrilSession oSes = DAO.getAdminSession("EditEmployee");
    CustomerAccount oAcc = new CustomerAccount(oSes.getDms().getDocument(getSessionAttribute("customer_account_docid")));
    Collection<TaxPayer> taxpayers = oAcc.taxpayers(oSes).list(oSes);
    oSes.disconnect();
    oSes.close();
    return taxpayers;
  }
View Full Code Here

      clients = (Collection<Client>) Cache.getObject(getSessionAttribute("customer_account_docid")+"clients");
    } catch (Exception e) {
      Log.out.error("EditConfig.getClients() Cache.getObject("+getSessionAttribute("customer_account_docid")+"clients) "+e.getClass().getName()+" "+e.getMessage(), e);
    }
    if (null==clients) {
      AtrilSession oSes = DAO.getAdminSession("CaptureInvoice");
      CustomerAccount oAcc = new CustomerAccount(oSes.getDms().getDocument(getSessionAttribute("customer_account_docid")));
      clients = oAcc.clients(oSes).list(oSes);
      for (Client oCli : clients)
        if (oCli.getTaxId().length()>0)
          oCli.setBusinessName(oCli.getBusinessName()+" ("+oCli.getTaxId()+")");
      oSes.disconnect();
      oSes.close();
      try {
        Cache.putEntry(getSessionAttribute("customer_account_docid")+"clients", clients);
      } catch (Exception e) {
        Log.out.error("CaptureInvoice.getClients() Cache.putEntry("+getSessionAttribute("customer_account_docid")+"clients) "+e.getClass().getName()+" "+e.getMessage(), e);
      }
View Full Code Here

      oHlr = new MailSessionHandler();
    } catch (IOException ioe) {
      Log.out.error("AsyncSendInvitation new MailSessionHandler() "+ioe.getClass().getName()+" "+ioe.getMessage(), ioe);
    }
     
      AtrilSession oSes = DAO.getAdminSession("AsyncSendInvitation");
      oSes.autoCommit(true);
      Dms oDms = oSes.getDms();
    CustomerAccount oAcc = new CustomerAccount(oDms, sAccId);
     
    for (int t=0; t<aTxprs.length; t++) {
      String sTxpId = aTxprs[t];
        TaxPayer oTxp = new TaxPayer (oDms, sTxpId);

        try {

          sUid = User.forEmail(sEmail);
        oUsr = new User(oSes, sUid);
        try {
          oUsr.allowTaxPayer(oSes, oTxp.id());
        } catch (Exception xcpt) {
          Log.out.error("AsyncSendInvitation User.allowTaxPayer() "+xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
        }

        } catch (ElementNotFoundException enfe) {

        String sPwd = Gadgets.generateRandomId(6, "abcdefghjkmnpqrtuvwxyz", Character.LOWERCASE_LETTER);
        sUid = User.create(oSes, sRec1stName, sRec2ndName, sRecEmail, sPwd, false).id();
        oUsr = new User(oSes, sUid);
        oUsr.canApproveInvoices(bApprove);
        oUsr.canSettleBillNotes(bSettle);
        oUsr.canUsePremiumCaptureServiceFlavor(bPremium);
        oUsr.setRole(oSes, oAcc, Role.user);
        oUsr.save(oSes);     

        try {
          oUsr.allowTaxPayer(oSes, oTxp.id());
        } catch (Exception xcpt) {
          Log.out.error("AsyncSendInvitation User.allowTaxPayer() "+xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
        }
       
        HashMap oMap = FastStreamReplacer.createMap(new String[] {"1","2","3","4","5","6"},
                              new String[] {oUsr.getFirstName(), sSender1stName, sSender2ndName, oTxp.getBusinessName() + (aTxprs.length>1 ? " y a otras " + String.valueOf(aTxprs.length-1) + " más": ""), oUsr.id(), sPwd});
          ByteArrayOutputStream oByOut = new ByteArrayOutputStream();
          PrintStream oPrt = new PrintStream(oByOut);             
          try {
              Log.out.debug("sending email");
          oHlr.sendMessage("Acceso a zesped", "Zesped", "noreply@zesped.com", "noreply@zesped.com",
                           new String[] {sEmail}, RecipientType.TO, oRpl.replace(oTxt, oMap), oRpl.replace(oHtm, oMap),
                           "ISO8859_1", null, null, null, oPrt);
        } catch (Exception xcpt) {
          Log.out.error("AsyncSendInvitation MailSessionHandler.sendMessage() "+xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
        }
          oPrt.close();
          Log.out.info(oByOut.toString());
          try {
          oByOut.close();
        } catch (IOException ignore) { }
        DAO.log(oSes, oUsr.getDocument(), User.class, "SEND INVITATION", AtrilEvent.Level.INFO, sEmail);
      }
        if (bCreateEmp) {
        Employees oEms = oTxp.employees(oSes);
        try {
          oEms.seek(oSes, oUsr.getNickName());
        } catch (InstantiationException xcpt) {
          Log.out.error("AsyncSendInvitation Employees.seek() "+xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
        } catch (IllegalAccessException xcpt) {
          Log.out.error("AsyncSendInvitation Employees.seek() "+xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);     
        } catch (ElementNotFoundException enfe) {
              Log.out.debug("creating employee");
          Employee oEmp = new Employee(oSes, oEms);
            oEmp.setUuid(oUsr.getNickName());
            oEmp.setName(oUsr.getFirstName()+" "+oUsr.getLastName());
            oEmp.setEmployeeId("");
            oEmp.setTaxId("");
            oEmp.setActive(true);
            oEmp.save(oSes);
            if (0==t) oActivationInfo.put("employee_uuid", oUsr.getNickName());
        }
      }           
    } // next

    oActivationInfo.put("nickname", oUsr.getNickName());
    oActivationInfo.put("password", oUsr.getPassword());
    oActivationInfo.put("fullname", oUsr.getFirstName()+" "+oUsr.getLastName());
    oActivationInfo.put("email", oUsr.getEmail());
    oActivationInfo.put("user_docid", oUsr.id());
    oActivationInfo.put("user_uuid", oUsr.getString("user_uuid"));
    oActivationInfo.put("businessname", oAcc.getBusinessName());
    oActivationInfo.put("customer_acount", oAcc.getUuid());
    oActivationInfo.put("customer_account_docid", oAcc.id());
    oActivationInfo.put("taxpayer_docid", aTxprs[0]);
    oActivationInfo.put("can_approve", oUsr.getString("can_approve"));
    oActivationInfo.put("can_settle", oUsr.getString("can_settle"));
    oActivationInfo.put("can_premium", oUsr.getString("can_premium"));
    oActivationInfo.put("role", Role.user);
    oActivationInfo.put("hasorders", new Boolean(oAcc.orders(oSes).count()>0));
     
    try {
      Cache.putEntry(oUsr.id()+"activationinfo", oActivationInfo);
    } catch (Exception xcpt) {
      Log.out.error("AsyncSendInvitation Cache.putEntry() "+xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
    }
   
    oSes.disconnect();
    oSes.close();
      Log.out.debug("End AsyncSendInvitation()");
  }
View Full Code Here

      clients = (Collection<Client>) Cache.getObject(getSessionAttribute("customer_account_docid")+"clients");
    } catch (Exception e) {
      Log.out.error("CaptureInvoice.getClients() Cache.getObject("+getSessionAttribute("customer_account_docid")+"clients) "+e.getClass().getName()+" "+e.getMessage(), e);
    }
    if (null==clients) {
      AtrilSession oSes = DAO.getAdminSession("CaptureInvoice");
      CustomerAccount oAcc = new CustomerAccount(oSes.getDms().getDocument(getSessionAttribute("customer_account_docid")));
      clients = oAcc.clients(oSes).list(oSes);
      for (Client oCli : clients)
        if (oCli.getTaxId().length()>0)
          oCli.setBusinessName(oCli.getBusinessName()+" ("+oCli.getTaxId()+")");
      oSes.disconnect();
      oSes.close();
      try {
        Cache.putEntry(getSessionAttribute("customer_account_docid")+"clients", clients);
      } catch (Exception e) {
        Log.out.error("CaptureInvoice.getClients() Cache.putEntry("+getSessionAttribute("customer_account_docid")+"clients) "+e.getClass().getName()+" "+e.getMessage(), e);
      }
View Full Code Here

    return serviceflavor==null ? CaptureServiceFlavor.BASIC : serviceflavor;
  }

  @DefaultHandler
  public Resolution form() {
    AtrilSession oSes = DAO.getAdminSession("CaptureInvoice");
    User oUsr = new User();
    try {
      oUsr.load(oSes, getSessionAttribute("user_docid"));
      setScanDeviceName(oUsr.defaultScanner(oSes).name());
      setCaptureType(oUsr.defaultCaptureType(oSes).name());
      if (getSessionAttribute("incoming_deposits")==null) {
        TaxPayer oTxp = new TaxPayer (oSes.getDms(), getSessionAttribute("taxpayer_docid"));
        setSessionAttribute("incoming_deposits", oTxp.incomingDeposits(oSes));
      }
      oSes.disconnect();
      oSes.close();
    } catch (Exception xcpt) {
      Log.out.error("CaptureInvoice.form() "+xcpt.getClass().getName()+" "+xcpt.getMessage());
      setScanDeviceName("Twain");
      setCaptureType("UnsignedSinglePageFullDuplexNoGUI");
      if (oSes.isConnected()) oSes.disconnect();
      if (oSes.isOpen()) oSes.close();
    }
    setFullDuplex(getCaptureType().indexOf("FullDuplex")>0);
    setGUI(getCaptureType().indexOf("NoGUI")<0);
    setSign(getCaptureType().startsWith("Signed"));
    setServerSign(getCaptureType().startsWith("ServerSigned"));
View Full Code Here

    public static void main(String[] args) throws Exception {
      ModelManager oMan = new ModelManager();
      DAO oDao = new DAO();   
      oDao.init(oMan.getConnectionProperties());
      AtrilSession oSes = DAO.getAdminSession("CityWriter");
      oSes.autoCommit(true);
      oMan.writeCities(oSes, "es");
      oSes.disconnect();
      oSes.close();
      oDao.destroy();
      }
View Full Code Here

  public CaptureService getCaptureService() {
    return null;
  }

  public Collection<TaxPayer> getTaxPayers() throws ElementNotFoundException, NotEnoughRightsException, DmsException, InstantiationException, IllegalAccessException {
    AtrilSession oSes = DAO.getAdminSession("EditUser");
    CustomerAccount oAcc = new CustomerAccount(oSes.getDms().getDocument(getSessionAttribute("customer_account_docid")));
    Collection<TaxPayer> taxpayers = oAcc.taxpayers(oSes).list(oSes);
    oSes.disconnect();
    oSes.close();
    return taxpayers;
  }
View Full Code Here

TOP

Related Classes of es.ipsa.atril.sec.authentication.AtrilSession

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.