Package es.ipsa.atril.sec.authentication

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


    return getString("total_price");
  }
 
  public ArrayList<OrderLine> lines() {
    ArrayList<OrderLine> aLines = new ArrayList<OrderLine>();
    AtrilSession oSes = null;
    try {
      oSes = DAO.getAdminSession("Order.lines");
      Dms oDma = oSes.getDms();
      for (Document d : oDma.getDocument(id()).children())
        aLines.add(new OrderLine(oDma.getDocument(d.id())));
      oSes.disconnect();
      oSes.close();
      oSes = null;
    } finally {
      if (oSes != null) {
        if (oSes.isConnected()) {
          oSes.disconnect();
        }
        if (oSes.isOpen()) {
          oSes.close();
        }
      }
    }
    return aLines;
  }
View Full Code Here


    return t;
  }

  public static Collection<CaptureType> list() {
    ArrayList<CaptureType> aCtps = new ArrayList<CaptureType>();
    AtrilSession oSes = DAO.getAdminSession("CaptureTypes");
    for (Document d : top(oSes).getDocument().children()) {
      if (d.type().name().equals("CaptureType")) {
        CaptureType c = new CaptureType();
        c.setDocument(d);
        aCtps.add(c);                   
      }
    }
    oSes.disconnect();
    oSes.close();   
    return aCtps;
 
View Full Code Here

  public Resolution buy() {
      Order order = new Order();
      try {
        connect();
        AtrilSession oSes = getSession();
        Dms oDms = oSes.getDms();
        CustomerAccount cacc = new CustomerAccount(oDms, getSessionAttribute("customer_account_docid"));
        order = cacc.createOrder(oSes);
        order.put("user_id", getSessionAttribute("user_docid"));
        order.put("credits_bought", selectedProduct.getCredits());
        order.save(oSes);
View Full Code Here

  private static CountryNameComparator oCntrCmp = new Countries().new CountryNameComparator();

  public static Collection<Country> list() {
    if (aCntrs==null) {
      AtrilSession oSes = DAO.getAdminSession("Countries");
      Dms oDms = oSes.getDms();
      SortableList<Document> oLst = (SortableList<Document>) oDms.query("Country");
      aCntrs = new ArrayList<Country>();
      for (Document d : oLst) {
        Country c = new Country();
        c.setDocument(oDms.getDocument(d.id()));
        aCntrs.add(c);
      } // next
      oSes.disconnect();
      oSes.close();   
      Collections.sort(aCntrs, oCntrCmp);
    }
    return aCntrs;
  }
View Full Code Here

    throws ClassCastException, RuntimeException, IllegalStateException, NullPointerException,
           AttributeTypeHasValuesException, NotYetConnectedException, DmsException, DmsDocumentModificationException {
    if (oDoc==null) throw new IllegalStateException(getTypeName()+" document not set before calling save() method");

    if (DAO.checkConstraints) {
      AtrilSession oAdm = DAO.getAdminSession("checkConstraints");
      Dms oDms = oAdm.getDms();
      DocumentIndexer oIdx = oAdm.getDocumentIndexer();
      final Attr[] aAttrs = attributes();
      final int nAttrs = (aAttrs==null ? 0 : aAttrs.length);
      try {
        for (int a=0; a<nAttrs; a++) {
          if (aAttrs[a].required && isNull(aAttrs[a].name)) throw new NullPointerException(getTypeName()+" attribute "+aAttrs[a].name+" is required");
          if (aAttrs[a].unique && !isNull(aAttrs[a].name)) {
            List<Document> oLst;
            if (aAttrs[a].dataType.equals(DataType.STRING))
              if (getString(aAttrs[a].name).indexOf("'")<0)
                oLst = oDms.query(getTypeName()+"$"+aAttrs[a].name+"='"+escape(getString(aAttrs[a].name))+"'");
              else
              oLst = null;
            else if (aAttrs[a].dataType.equals(DataType.NUMBER))
                oLst = oDms.query(getTypeName()+"$"+aAttrs[a].name+"="+get(aAttrs[a].name));
            else
              oLst = null;
            if (null!=oLst) {
              if (!oLst.isEmpty()) {
                String p = parentId();           
                for (Document d : oLst) {
                  String q = d.parents().get(0).id();
                  if (p.equals(q) && !d.id().equals(getId()) &&
                    d.attribute(aAttrs[a].name).toString().equals(get(aAttrs[a].name))) {
                    Log.out.debug(getTypeName()+" attribute "+aAttrs[a].name+" unique constraint violation for value "+get(aAttrs[a].name)+" parent document id. is "+p+" previous document id. is "+d.id()+" current document id. is "+getId());
                      throw new DmsException(getTypeName()+" attribute "+aAttrs[a].name+" unique constraint violation for value "+get(aAttrs[a].name));
                    } // fi             
                }
              } // fi             
            }
          } // fi (unique)
          if (aAttrs[a].fk!=null && !isNull(aAttrs[a].name)) {
            try {
              BaseModelObject oObj = aAttrs[a].fk.doctype.newInstance();
              if (null==oObj.exists(oAdm, aAttrs[a].fk.attrib, get(aAttrs[a].name).toString())) {
                  throw new DmsException(getTypeName()+" attribute "+aAttrs[a].name+" foreign key violation "+get(aAttrs[a].name).toString()+" referencing "+oObj.getTypeName()+"."+aAttrs[a].fk.attrib);
              }
            } catch (InstantiationException e) {
              Log.out.error("BaseModelObject.save() InstantiationException "+e.getMessage());
            } catch (IllegalAccessException e) {
              Log.out.error("BaseModelObject.save() IllegalAccessException "+e.getMessage());
            }
          } // fi (foreign key)
          if (aAttrs[a].cc!=null) {
            if (!aAttrs[a].cc.check(oAdm, oIdx, this))
              throw new DmsException(getTypeName()+" attribute "+aAttrs[a].name+" constraint violation "+aAttrs[a].cc.getClass().getName());
          }
        } // next
      } finally {
        if (oAdm!=null) {
          if (oAdm.isConnected()) oAdm.disconnect();
          if (oAdm.isOpen()) oAdm.close();         
        }       
      }
    } // fi
    AttributeMultiValue oAttr;
    Iterator<String> oKeys = keySet().iterator();
View Full Code Here

  }

  @Override
  protected void setDocument(Document oDoc) {
    super.setDocument(oDoc);
    AtrilSession oSes = DAO.getAdminSession("Country");
    states(oSes);
    oSes.disconnect();
    oSes.close();   
  }
View Full Code Here

   
    public Resolution deleteOrder(){
       try {
      String order_id = getContext().getRequest().getParameter("order_id");
      connect();
      AtrilSession oSes = getSession();
      Dms oDms = oSes.getDms();
      Order oOrder = new Order(oDms, order_id);
      BigDecimal oStatus = oOrder.getBigDecimal("status_number");
      if (oStatus != null && (oStatus.compareTo(Tpv.PAGADO) != 0 && oStatus.compareTo(Tpv.PENDIENTE_CONFIRMACION) != 0)) {
        oOrder.getDocument().deleteWithChildren();
        oSes.commit();
      }
      disconnect();
      return new ForwardResolution("");
    } catch (StorageException ex) {
      Exceptions.printStackTrace(ex);
View Full Code Here

  private String recipient, biller;

  private AccountingAccount account;

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

    }
  }
 
  public void grant(BaseModelObject... aObjs)
    throws AuthorizationException,ElementNotFoundException {
    AtrilSession oSes = DAO.getAdminSession("CustomerAccount.grant");
    AuthorizationManager oAum = oSes.getAuthorizationManager();   
    Group oGuestsGrp = getGuestsGroup(oAum);
    Group oUsersGrp = getUsersGroup(oAum);
    Group oOpersGrp = Zesped.getOperatorsGroup(oAum);
    Group oAdminsGrp = getAdminsGroup(oAum);
    UsersGroup oGgrp = new UsersGroup(oAum, oGuestsGrp);
    UsersGroup oUgrp = new UsersGroup(oAum, oUsersGrp);
    UsersGroup oOgrp = new UsersGroup(oAum, oOpersGrp);
    UsersGroup oAgrp = new UsersGroup(oAum, oAdminsGrp);   
    for (BaseModelObject oObj : aObjs) {
      Document oDoc = oObj.getDocument();
      oGgrp.grantReadOnly(oDoc);
      oUgrp.grantAll(oDoc);
      oOgrp.grantAll(oDoc);
      oAgrp.grantAll(oDoc);
    }
    oSes.commit();
    if (oSes.isConnected()) oSes.disconnect();
    if (oSes.isOpen()) oSes.close();
  }
View Full Code Here

    if (sCaptureServiceFlavorId==null) throw new NullPointerException("CaptureServiceFlavor.getCaptureServiceFlavor() CaptureService Flavor Id cannot be null");
    if (sCaptureServiceFlavorId.length()==0) throw new NullPointerException("CaptureServiceFlavor.getCaptureServiceFlavor() CaptureService Flavor Id cannot be empty");
    CaptureServiceFlavor oSrvFlv;
    if (oServFlvrs==null) {
      oServFlvrs = new HashMap<String, CaptureServiceFlavor>();
      AtrilSession oSes = DAO.getAdminSession("CaptureServiceFlavors");
      Dms oDms = oSes.getDms();
      Zesped z = Zesped.top(oSes);
      for (Document d : z.getDocument().children()) {
        if (d.type().name().equals("CaptureServiceFlavor")) {
          oSrvFlv = new CaptureServiceFlavor(oDms.getDocument(d.id()));
          oServFlvrs.put(oSrvFlv.uid(), oSrvFlv);
        }
      }
      oSes.disconnect();
      oSes.close();
    }
    oSrvFlv = oServFlvrs.get(sCaptureServiceFlavorId);
    if (null==oSrvFlv) throw new ElementNotFoundException("No CaptureService Flavor was found with Id. "+sCaptureServiceFlavorId);
    return oSrvFlv;
  }
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.