<p>Process entity request.</p>
@param pRqVs request scoped vars
@param pRqDt Request Data
@throws Exception - an exception
509318
@Override
  public final void process(final Map<String, Object> pRqVs,
    final IRequestData pRqDt) throws Exception {
    OnlineBuyer buyer = this.buySr.getAuthBuyr(pRqVs, pRqDt);
    if (buyer == null) {
      String procNm = pRqDt.getParameter("nmPrcRed");
      IProcessor proc = this.procFac.lazyGet(pRqVs, procNm);
      proc.process(pRqVs, pRqDt);
      return;
    }
    String orIdSt = pRqDt.getParameter("orId");
    String sorIdSt = pRqDt.getParameter("sorId");
    if (orIdSt != null || sorIdSt != null) { //print:
     if (orIdSt != null) { //order
        Long orId = Long.valueOf(orIdSt);
        CustOrder or = this.srvOrm.retrieveEntityById(pRqVs,
          CustOrder.class, orId);
        String tbn = CustOrderGdLn.class.getSimpleName();
        pRqVs.put(tbn + "itsOwnerdeepLevel", 1);
        or.setGoods(this.srvOrm.retrieveListWithConditions(
            pRqVs, CustOrderGdLn.class, "where ITSOWNER=" + orId));
        pRqVs.remove(tbn + "itsOwnerdeepLevel");
        tbn = CustOrderSrvLn.class.getSimpleName();
        pRqVs.put(tbn + "itsOwnerdeepLevel", 1);
        or.setServs(this.srvOrm.retrieveListWithConditions(
            pRqVs, CustOrderSrvLn.class, "where ITSOWNER=" + orId));
        pRqVs.remove(tbn + "itsOwnerdeepLevel");
        tbn = CustOrderTxLn.class.getSimpleName();
        pRqVs.put(tbn + "itsOwnerdeepLevel", 1);
        or.setTaxes(this.srvOrm.retrieveListWithConditions(
            pRqVs, CustOrderTxLn.class, "where ITSOWNER=" + orId));
        pRqVs.remove(tbn + "itsOwnerdeepLevel");
        pRqDt.setAttribute("entity", or);
        pRqDt.setAttribute("mngUvds", this.mngUvd);
        pRqDt.setAttribute("srvOrm", this.srvOrm);
        pRqDt.setAttribute("srvDate", this.srvDate);
        pRqDt.setAttribute("hldCnvFtfsNames", this.hldFldCnv);
        pRqDt.setAttribute("fctCnvFtfs", this.facFldCnv);
        Map<Class<?>, List<?>> olm = new LinkedHashMap<Class<?>, List<?>>();
        pRqDt.setAttribute("ownedListsMap", olm);
        olm.put(CustOrderGdLn.class, or.getGoods());
        olm.put(CustOrderSrvLn.class, or.getServs());
        olm.put(CustOrderTxLn.class, or.getTaxes());
      } else { //S.E. order:
        Long orId = Long.valueOf(sorIdSt);
        CuOrSe or = this.srvOrm.retrieveEntityById(pRqVs,
          CuOrSe.class, orId);
        String tbn = CuOrSeGdLn.class.getSimpleName();
        pRqVs.put(tbn + "itsOwnerdeepLevel", 1);
        or.setGoods(this.srvOrm.retrieveListWithConditions(
            pRqVs, CuOrSeGdLn.class, "where ITSOWNER=" + orId));
        pRqVs.remove(tbn + "itsOwnerdeepLevel");
        tbn = CuOrSeSrLn.class.getSimpleName();
        pRqVs.put(tbn + "itsOwnerdeepLevel", 1);
        or.setServs(this.srvOrm.retrieveListWithConditions(
            pRqVs, CuOrSeSrLn.class, "where ITSOWNER=" + orId));
        pRqVs.remove(tbn + "itsOwnerdeepLevel");
        tbn = CuOrSeTxLn.class.getSimpleName();
        pRqVs.put(tbn + "itsOwnerdeepLevel", 1);
        or.setTaxes(this.srvOrm.retrieveListWithConditions(
            pRqVs, CuOrSeTxLn.class, "where ITSOWNER=" + orId));
        pRqVs.remove(tbn + "itsOwnerdeepLevel");
        pRqDt.setAttribute("entity", or);
        pRqDt.setAttribute("mngUvds", this.mngUvd);
        pRqDt.setAttribute("srvOrm", this.srvOrm);
        pRqDt.setAttribute("srvDate", this.srvDate);
        pRqDt.setAttribute("hldCnvFtfsNames", this.hldFldCnv);
        pRqDt.setAttribute("fctCnvFtfs", this.facFldCnv);
        Map<Class<?>, List<?>> olm = new LinkedHashMap<Class<?>, List<?>>();
        pRqDt.setAttribute("ownedListsMap", olm);
        olm.put(CuOrSeGdLn.class, or.getGoods());
        olm.put(CuOrSeSrLn.class, or.getServs());
        olm.put(CuOrSeTxLn.class, or.getTaxes());
      }
    } else { //page:
      page(pRqVs, pRqDt, buyer);
    }
  }
677002
public void execute() throws Exception {
        ActionRequest request = requestBuilder.request();

        //todo: maby change to instanceof multi?
        if(requestBuilder instanceof JoinRequestBuilder){
            executeJoinRequestAndSendResponse();
        }
		else if (request instanceof SearchRequest) {
			client.search((SearchRequest) request, new RestStatusToXContentListener<SearchResponse>(channel));
		} else if (requestBuilder instanceof SqlElasticDeleteByQueryRequestBuilder) {
            throw new UnsupportedOperationException("currently not support delete on elastic 2.0.0");
        }
        else if(request instanceof GetIndexRequest) {
            this.requestBuilder.getBuilder().execute( new GetIndexRequestRestListener(channel, (GetIndexRequest) request));
        }


		else {
			throw new Exception(String.format("Unsupported ActionRequest provided: %s", request.getClass().getName()));
		}
	}
1224571
@Override
  public final void process(final Map<String, Object> pRqVs,
    final IRequestData pRqDt) throws Exception {
    Cart cart = this.srvCart.getShoppingCart(pRqVs, pRqDt, false, true);
    if (cart == null) {
      redir(pRqVs, pRqDt);
      return;
    }
    if (EPaymentMethod.PAYPAL.equals(cart.getPayMeth())) {
      //TODO partially online, SE
      List<PayMd> payMds = this.srvOrm.retrieveListWithConditions(pRqVs,
        PayMd.class, "where ITSNAME='PAYPAL'");
      if (payMds.size() != 1) {
        throw new Exception("There is no properly PPL PayMd");
      } else {
        pRqDt.setAttribute("pmde", payMds.get(0).getMde());
      }
    }
    TradingSettings ts = (TradingSettings) pRqVs.get("tradSet");
    AccSettings as = (AccSettings) pRqVs.get("accSet");
    TaxDestination txRules = this.srvCart.revealTaxRules(pRqVs, cart, as);
    //redo prices and taxes:
    for (CartLn cl : cart.getItems()) {
      if (!cl.getDisab() && !cl.getForc()) {
        this.srvCart.makeCartLine(pRqVs, cl, as, ts, txRules, true, true);
        this.srvCart.makeCartTotals(pRqVs, ts, cl, as, txRules);
      }
    }
    boolean isCompl = true;
    Purch pur = retNewOrds(pRqVs, cart.getBuyer());
    String cond;
    for (CartLn cl : cart.getItems()) {
      if (cl.getDisab()) {
        continue;
      }
      Class<?> itPlCl;
      String serBus = null;
      if (cl.getItTyp().equals(EShopItemType.GOODS)) {
        itPlCl = GoodsPlace.class;
      } else if (cl.getItTyp().equals(EShopItemType.SERVICE)) {
        itPlCl = ServicePlace.class;
        serBus = SerBus.class.getSimpleName();
      } else if (cl.getItTyp().equals(EShopItemType.SESERVICE)) {
        itPlCl = SeServicePlace.class;
        serBus = SeSerBus.class.getSimpleName();
      } else {
        itPlCl = SeGoodsPlace.class;
      }
      if (serBus == null || cl.getDt1() == null) {
        // good or non-bookable service
        cond = "where ITSQUANTITY>0 and ITEM=" + cl.getItId();
      } else {
        cond = "left join (select distinct SERV from " + serBus + " where SERV="
      + cl.getItId() + " and FRTM>=" + cl.getDt1().getTime() + " and TITM<"
    + cl.getDt2().getTime() + ") as " + serBus + " on " + serBus + ".SERV="
  + itPlCl.getSimpleName() + ".ITEM where ITEM=" + cl.getItId()
+ " and ITSQUANTITY>0 and " + serBus + ".SERV is null";
      }
      Set<String> ndFlNm = new HashSet<String>();
      ndFlNm.add("itsId");
      ndFlNm.add("itsName");
      pRqVs.put("PickUpPlaceneededFields", ndFlNm);
      pRqVs.put(itPlCl.getSimpleName() + "itemdeepLevel", 1); //only ID
      @SuppressWarnings("unchecked")
      List<AItemPlace<?, ?>> places = (List<AItemPlace<?, ?>>) getSrvOrm()
        .retrieveListWithConditions(pRqVs, itPlCl, cond);
      pRqVs.remove(itPlCl.getSimpleName() + "itemdeepLevel");
      pRqVs.remove("PickUpPlaceneededFields");
      if (places.size() > 1 && serBus != null && cl.getDt1() != null) {
        //for bookable service it's ambiguous - same service (e.g. appointment
        //to DR.Jonson) is available at same time in two different places)
        //for non-bookable service, e.g. for delivering place means
        //starting-point, but it should be selected automatically TODO
        //for goods: TODO
        //1. buyer chooses place (in filter), so use this place
        //2. buyer will pickups by yourself from different places,
        // but it must chooses them (in filter) in this case.
        // As a result places should ordered by itsQuantity and removed items
        // that are out of filter.
        isCompl = false;
        String errs = "!Wrong places for item name/ID/type: " + cl.getItsName()
          + "/" + cl.getItId() + "/" + cl.getItTyp();
        if (cart.getDescr() == null) {
          cart.setDescr(errs);
        } else {
          cart.setDescr(cart.getDescr() + errs);
        }
        cart.setErr(true);
        getSrvOrm().updateEntity(pRqVs, cart);
        this.log.warn(pRqVs, PrcCheckOut.class, errs);
        break;
      } else { //only/multiply place/s with non-zero availability
        BigDecimal avQu = BigDecimal.ZERO;
        for (AItemPlace<?, ?> pl : places) {
          avQu = avQu.add(pl.getItsQuantity());
        }
        if (avQu.compareTo(cl.getQuant()) == -1) {
          isCompl = false;
          cl.setAvQuan(avQu);
          String errs = "!Not available item name/ID/type/quant/avail: "
            + cl.getItsName() + "/" + cl.getItId() + "/" + cl.getItTyp()
              + "/" + cl.getQuant() + "/" + avQu;
          this.log.warn(pRqVs, PrcCheckOut.class, errs);
        }
      }
      if (isCompl && cl.getPrice().compareTo(BigDecimal.ZERO) == 1) {
        //without free delivering:
        if (cl.getSeller() == null) {
          makeOrdLn(pRqVs, pur.getOrds(), null, cl, ts);
        } else {
          makeSeOrdLn(pRqVs, pur.getSords(), cl.getSeller(), null, cl, ts);
        }
      } else {
        getSrvOrm().updateEntity(pRqVs, cl);
      }
    }
    pRqDt.setAttribute("cart", cart);
    if (txRules != null) {
      pRqDt.setAttribute("txRules", txRules);
    }
    if (!isCompl) {
      redir(pRqVs, pRqDt);
    } else {
      saveOrds(pRqVs, pur, cart);
      saveSords(pRqVs, pur, cart);
      pRqDt.setAttribute("orders", pur.getOrds());
      pRqDt.setAttribute("sorders", pur.getSords());
    }
  }
355372
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        if (!request.getServletPath().endsWith("insecure")) {
            response.addHeader("Content-Security-Policy", buildCSPHeader());
        }
        request.getRequestDispatcher("WEB-INF/chatq.jspx").forward(request, response);
    }
785039
@Override
  public final void process(final Map<String, Object> pRqVs,
    final IRequestData pRqDt) throws Exception {
    OnlineBuyer buyer = this.buySr.getBuyr(pRqVs, pRqDt);
    if (buyer == null) {
      buyer = this.buySr.createBuyr(pRqVs, pRqDt);
    }
    String nm = pRqDt.getParameter("nm");
    String em = pRqDt.getParameter("em");
    String pw = pRqDt.getParameter("pw");
    String pwc = pRqDt.getParameter("pwc");
    long now = new Date().getTime();
    String tbn = OnlineBuyer.class.getSimpleName();
    pRqDt.setAttribute("buyr", buyer);
    if (buyer.getRegEmail() == null) { //unregistered:
      if (nm != null && pw != null && pwc != null && em != null) {
        //creating:
        if (nm.length() > 2 && pw.length() > 7 && pw.equals(pwc)
          && em.length() > 5) {
          Set<String> ndFl = new HashSet<String>();
          ndFl.add("itsId");
          pRqVs.put(tbn + "neededFields", ndFl);
          List<OnlineBuyer> brs = getSrvOrm().retrieveListWithConditions(pRqVs,
            OnlineBuyer.class, "where REGEMAIL='" + em + "'");
          pRqVs.remove(tbn + "neededFields");
          if (brs.size() == 0) {
            buyer.setItsName(nm);
            buyer.setRegisteredPassword(pw);
            buyer.setRegEmail(em);
            buyer.setLsTm(now);
            UUID buseid = UUID.randomUUID();
            buyer.setBuSeId(buseid.toString());
            if (buyer.getIsNew()) {
              this.srvOrm.insertEntity(pRqVs, buyer);
            } else {
              this.srvOrm.updateEntity(pRqVs, buyer);
            }
            pRqDt.setCookieValue("cBuyerId", buyer.getItsId().toString());
            pRqDt.setCookieValue("buSeId", buyer.getBuSeId());
          } else if (brs.size() == 1) {
            pRqDt.setAttribute("errMsg", "emBusy");
          } else {
            getLog().error(pRqVs, PrLog.class,
              "Several users with same email!: " + em);
          }
        } else {
          pRqDt.setAttribute("errMsg", "buyCrRul");
        }
      } else if (pw != null && em != null) {
        //login from new browser
        pRqVs.put(tbn + "regCustomerdeepLevel", 1);
        pRqVs.put(tbn + "taxDestplacedeepLevel", 1);
        List<OnlineBuyer> brs = getSrvOrm().retrieveListWithConditions(
          pRqVs, OnlineBuyer.class, "where REGISTEREDPASSWORD='" + pw
            + "' and REGEMAIL='" + em + "'");
        pRqVs.remove(tbn + "regCustomerdeepLevel");
        pRqVs.remove(tbn + "taxDestplacedeepLevel");
        if (brs.size() == 1) {
          //free buyer and moving its cart by fast updates:
          mkFreBuyr(pRqVs,  pRqDt, buyer, brs.get(0));
        } else if (brs.size() == 0) {
          pRqDt.setAttribute("errMsg", "wrong_em_password");
        } else {
          getLog().error(pRqVs, PrLog.class,
            "Several users with same password and email!: " + em);
        }
      } else {
        spam(pRqVs, pRqDt);
      }
    } else { //registered:
      if (now - buyer.getLsTm() < 1800000L && buyer.getBuSeId() != null) {
        //there is opened session:
        String buSeId = pRqDt.getCookieValue("buSeId");
        if (buyer.getBuSeId().equals(buSeId)) {
          //authorized requests:
          String zip = pRqDt.getParameter("zip");
          String adr1 = pRqDt.getParameter("adr1");
          if (nm != null && zip != null  && adr1 != null) {
            //change name, shipping address:
            String cnt = pRqDt.getParameter("cnt");
            String cit = pRqDt.getParameter("cit");
            String adr2 = pRqDt.getParameter("adr2");
            String phn = pRqDt.getParameter("phn");
            if (nm.length() > 2 && zip.length() > 2 && adr1.length() > 2) {
              buyer.setItsName(nm);
              buyer.setRegZip(zip);
              buyer.setRegAddress1(adr1);
              buyer.setRegAddress2(adr2);
              buyer.setRegCountry(cnt);
              buyer.setRegCity(cit);
              buyer.setRegPhone(phn);
              buyer.setLsTm(now);
              this.srvOrm.updateEntity(pRqVs, buyer);
            } else {
              pRqDt.setAttribute("errMsg", "buyEmRul");
            }
          } else if (pw != null && pwc != null) {
            //change password:
            if (pw.length() > 7 && pw.equals(pwc)) {
              buyer.setRegisteredPassword(pw);
              buyer.setLsTm(now);
              this.srvOrm.updateEntity(pRqVs, buyer);
            } else {
              pRqDt.setAttribute("errMsg", "buyPwdRul");
            }
          } else {
            //logout action:
            buyer.setLsTm(0L);
            this.srvOrm.updateEntity(pRqVs, buyer);
          }
        } else { //either spam or buyer login from other browser without logout
          spam(pRqVs, pRqDt);
        }
      } else {
        //unauthorized requests:
        if (pw != null) {
          //login action:
          if (pw.equals(buyer.getRegisteredPassword())) {
            buyer.setLsTm(now);
            UUID buseid = UUID.randomUUID();
            buyer.setBuSeId(buseid.toString());
            pRqDt.setCookieValue("buSeId", buyer.getBuSeId());
            this.srvOrm.updateEntity(pRqVs, buyer);
          } else {
            pRqDt.setAttribute("errMsg", "wrong_password");
          }
        } else {
          spam(pRqVs, pRqDt);
        }
      }
    }
    String procNm = pRqDt.getParameter("nmPrcRed");
    IProcessor proc = this.procFac.lazyGet(pRqVs, procNm);
    proc.process(pRqVs, pRqDt);
  }
711735
@Override
  public final OnlineBuyer getBuyr(final Map<String, Object> pRqVs,
    final IRequestData pRqDt) throws Exception {
    Long buyerId = null;
    String buyerIdStr = pRqDt.getCookieValue("cBuyerId");
    if (buyerIdStr != null && buyerIdStr.length() > 0) {
       buyerId = Long.valueOf(buyerIdStr);
    }
    OnlineBuyer buyer = null;
    if (buyerId != null) {
      buyer = getSrvOrm().retrieveEntityById(pRqVs, OnlineBuyer.class, buyerId);
    }
    if (buyer != null && buyer.getRegEmail() != null
      && buyer.getBuSeId() != null) {
      String buSeId = pRqDt.getCookieValue("buSeId");
      if (!buyer.getBuSeId().equals(buSeId)) {
        this.spamHnd.handle(pRqVs, pRqDt, 100,
          "Buyer. Authorized invasion? cBuyerId: " + buyerIdStr);
        //buyer also might clears cookie, so it's need new authorization
        //new/free buyer will be used till authorization:
        buyer = null;
      }
    }
    return buyer;
  }
969938
@Override
  public final AItemSpecifics<T, ID> process(
    final Map<String, Object> pReqVars,
      final AItemSpecifics<T, ID> pEntity,
        final IRequestData pRequestData) throws Exception {
    String fileToUploadName = (String) pRequestData
      .getAttribute("fileToUploadName");
    OutputStream outs = null;
    InputStream ins = null;
    try {
      String filePath;
      if (pEntity.getStringValue1() == null) { //in base language:
        String ft = String.valueOf(new Date().getTime());
        filePath = this.webAppPath + File.separator
          + this.uploadDirectory + File.separator
            + ft + fileToUploadName;
        pEntity.setStringValue2(filePath);
        pEntity.setStringValue1(this.uploadDirectory
              + "/" + ft + fileToUploadName);
      } else { //I18N files:
        String fileLang = pRequestData.getParameter("fileLang");
        if (pEntity.getStringValue3() == null
          || !pEntity.getStringValue3().contains(fileLang)) {
          throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
            "notset_language");
        }
        int idhHtml = pEntity.getStringValue1().indexOf(".html");
        String urlWithoutHtml = pEntity.getStringValue1().substring(0, idhHtml);
        filePath = this.webAppPath + File.separator
          + urlWithoutHtml + "_" + fileLang + ".html";
      }
      ins = (InputStream) pRequestData.getAttribute("fileToUploadInputStream");
      outs = new BufferedOutputStream(new FileOutputStream(filePath));
      byte[] data = new byte[1024];
      int count;
      while ((count = ins.read(data)) != -1) {
        outs.write(data, 0, count);
      }
      outs.flush();
    } finally {
      if (ins != null) {
        ins.close();
      }
      if (outs != null) {
        outs.close();
      }
    }
    getSrvOrm().updateEntity(pReqVars, pEntity);
    return pEntity;
  }
110920
@SuppressWarnings("unchecked")
    public <T extends IEntity> T findById(T entity) throws FMSException {

        IntuitMessage intuitMessage = prepareFindById(entity);

        //execute interceptors
        executeInterceptors(intuitMessage);

        T returnEntity = null;
        IntuitResponse intuitResponse = (IntuitResponse) intuitMessage.getResponseElements().getResponse();
        if (intuitResponse != null) {
            //QBD service is returning object as QueryResponse while QBO is returning object as IntuitObject in IntuitResponse

            if (intuitResponse.getIntuitObject() != null) {
                JAXBElement<? extends IntuitEntity> intuitObject = intuitResponse.getIntuitObject();
                if (intuitObject != null) {
                    returnEntity = ((T) intuitObject.getValue());
                }
            } else if (intuitResponse.getQueryResponse() != null) {
                QueryResponse queryResponse = intuitResponse.getQueryResponse();
                List<JAXBElement<? extends IntuitEntity>> intuitObject = queryResponse.getIntuitObject();
                if (intuitObject != null && intuitObject.size() > 0) {
                    returnEntity = ((T) intuitObject.get(0).getValue());
                }
            }
        }
        return returnEntity;
    }
350958
public final void saveSords(final Map<String, Object> pRqVs,
    final Purch pPur, final Cart pCart) throws Exception {
    List<CuOrSe> dels = null;
    for (CuOrSe co : pPur.getSords()) {
      if (co.getCurr() == null) { //stored unused order
        //remove it and all its lines:
        for (CuOrSeGdLn gl : co.getGoods()) {
          for (CuOrSeGdTxLn gtl : gl.getItTxs()) {
            getSrvOrm().deleteEntity(pRqVs, gtl);
          }
          getSrvOrm().deleteEntity(pRqVs, gl);
        }
        for (CuOrSeSrLn sl : co.getServs()) {
          for (CuOrSeSrTxLn stl : sl.getItTxs()) {
            getSrvOrm().deleteEntity(pRqVs, stl);
          }
          getSrvOrm().deleteEntity(pRqVs, sl);
        }
        for (CuOrSeTxLn otlt : co.getTaxes()) {
          getSrvOrm().deleteEntity(pRqVs, otlt);
        }
        getSrvOrm().deleteEntity(pRqVs, co);
        if (dels == null) {
          dels = new ArrayList<CuOrSe>();
        }
        dels.add(co);
        continue;
      }
      if (co.getIsNew()) {
        getSrvOrm().insertEntity(pRqVs, co);
      }
      BigDecimal tot = BigDecimal.ZERO;
      BigDecimal subt = BigDecimal.ZERO;
      List<CuOrSeGdLn> delsGd = null;
      for (CuOrSeGdLn gl : co.getGoods()) {
        gl.setItsOwner(co);
        if (gl.getIsNew()) {
          getSrvOrm().insertEntity(pRqVs, gl);
        }
        if (gl.getItTxs() != null && gl.getItTxs().size() > 0) {
          for (CuOrSeGdTxLn gtl : gl.getItTxs()) {
            gtl.setItsOwner(gl);
            if (gtl.getIsNew()) {
              getSrvOrm().insertEntity(pRqVs, gtl);
            } else if (gl.getGood() == null || gtl.getTax() == null) {
              getSrvOrm().deleteEntity(pRqVs, gtl);
            } else {
              getSrvOrm().updateEntity(pRqVs, gtl);
            }
          }
        }
        if (!gl.getIsNew() && gl.getGood() == null) {
          getSrvOrm().deleteEntity(pRqVs, gl);
          if (delsGd == null) {
            delsGd = new ArrayList<CuOrSeGdLn>();
          }
          delsGd.add(gl);
        } else {
          tot = tot.add(gl.getTot());
          subt = subt.add(gl.getSubt());
          if (!gl.getIsNew()) {
            getSrvOrm().updateEntity(pRqVs, gl);
          }
        }
      }
      if (delsGd != null) {
        for (CuOrSeGdLn gl : delsGd) {
          co.getGoods().remove(gl);
        }
      }
      List<CuOrSeSrLn> delsSr = null;
      for (CuOrSeSrLn sl : co.getServs()) {
        sl.setItsOwner(co);
        if (sl.getIsNew()) {
          getSrvOrm().insertEntity(pRqVs, sl);
        }
        if (sl.getItTxs() != null && sl.getItTxs().size() > 0) {
          for (CuOrSeSrTxLn stl : sl.getItTxs()) {
            stl.setItsOwner(sl);
            if (stl.getIsNew()) {
              getSrvOrm().insertEntity(pRqVs, stl);
            } else if (sl.getService() == null || stl.getTax() == null) {
              getSrvOrm().deleteEntity(pRqVs, stl);
            } else {
              getSrvOrm().updateEntity(pRqVs, stl);
            }
          }
        }
        if (!sl.getIsNew() && sl.getService() == null) {
          getSrvOrm().deleteEntity(pRqVs, sl);
          if (delsSr == null) {
            delsSr = new ArrayList<CuOrSeSrLn>();
          }
          delsSr.add(sl);
        } else {
          tot = tot.add(sl.getTot());
          subt = subt.add(sl.getSubt());
          if (!sl.getIsNew()) {
            getSrvOrm().updateEntity(pRqVs, sl);
          }
        }
      }
      if (delsSr != null) {
        for (CuOrSeSrLn sl : delsSr) {
          co.getServs().remove(sl);
        }
      }
      BigDecimal totTx = BigDecimal.ZERO;
      for (CartTxLn ctl : pCart.getTaxes()) {
        if (ctl.getDisab() || ctl.getSeller() == null
          || !ctl.getSeller().getSeller().getItsId()
            .equals(co.getSel().getSeller().getItsId())) {
          continue;
        }
        CuOrSeTxLn otl = null;
        if (!co.getIsNew()) {
          for (CuOrSeTxLn otlt : co.getTaxes()) {
            if (otlt.getTax() == null) {
              otl = otlt;
              break;
            }
          }
        }
        if (otl == null) {
          otl = new CuOrSeTxLn();
          otl.setIsNew(true);
          co.getTaxes().add(otl);
        }
        otl.setItsOwner(co);
        Tax tx = new Tax();
        tx.setItsId(ctl.getTax().getItsId());
        tx.setItsName(ctl.getTax().getItsName());
        otl.setTax(tx);
        otl.setTot(ctl.getTot());
        otl.setTaxab(ctl.getTaxab());
        totTx = totTx.add(otl.getTot());
        if (otl.getIsNew()) {
          getSrvOrm().insertEntity(pRqVs, otl);
        } else {
          getSrvOrm().updateEntity(pRqVs, otl);
        }
      }
      if (!co.getIsNew()) {
        List<CuOrSeTxLn> delsTx = null;
        for (CuOrSeTxLn otlt : co.getTaxes()) {
          if (otlt.getTax() == null) {
            getSrvOrm().deleteEntity(pRqVs, otlt);
            if (delsTx == null) {
              delsTx = new ArrayList<CuOrSeTxLn>();
            }
            delsTx.add(otlt);
          }
        }
        if (delsTx != null) {
          for (CuOrSeTxLn tl : delsTx) {
            co.getTaxes().remove(tl);
          }
        }
      }
      co.setTot(tot);
      co.setSubt(subt);
      co.setTotTx(totTx);
      getSrvOrm().updateEntity(pRqVs, co);
    }
    if (dels != null) {
      for (CuOrSe co : dels) {
        pPur.getSords().remove(co);
      }
    }
  }
1363570
@Override
  public final void handle(final Map<String, Object> pReqVars,
    final IRequestData pRequestData) throws Exception {
    String processorName = pRequestData.getParameter("nmPrc");
    if (processorName == null) {
      //WHandlerAndJsp requires handle NULL request:
      return;
    }
    IProcessor proc = this.processorsFactory.lazyGet(pReqVars, processorName);
    proc.process(pReqVars, pRequestData);
  }
227177
private <T extends IEntity> IntuitMessage prepareVoidRequest(T entity) throws FMSException {
        IntuitMessage intuitMessage = new IntuitMessage();
        RequestElements requestElements = intuitMessage.getRequestElements();

        //set the request parameters
        Map<String, String> requestParameters = requestElements.getRequestParameters();
        requestParameters.put(RequestElements.REQ_PARAM_METHOD_TYPE, MethodType.POST.toString());
        requestParameters.put(RequestElements.REQ_PARAM_INCLUDE, OperationType.VOID.toString());

        requestElements.setContext(context);
        requestElements.setEntity(entity);
        requestElements.setObjectToSerialize(getSerializableObject(entity));

        return intuitMessage;
    }
703640
private <T extends IEntity> String prepareQBOUri(String entityName, Context context, 
			Map<String, String> requestParameters) throws FMSException {

		StringBuilder uri = new StringBuilder();
		if(entityName.equalsIgnoreCase("Taxservice"))
				{
					entityName = entityName + "/" + "taxcode";
				}
		
		// constructs request URI
		uri.append(getBaseUrl(Config.getProperty(Config.BASE_URL_QBO))).append("/").append(context.getRealmID()).append("/").append(entityName);
        addEntityID(requestParameters, uri);
        addEntitySelector(requestParameters, uri);
        addParentID(requestParameters, uri);

        // adds the built request param
      /*  if(requestParameters.equals("updateaccountontxns"))
        {
        	
    		uri.append("include=updateaccountontxns");

        }*/
		uri.append("?").append(buildRequestParams(requestParameters));
		// adds the generated request id as a parameter
		uri.append("requestid").append("=").append(context.getRequestID()).append("&");
		//set RequestId to null once appended, so the next random num can be generated
		context.setRequestID(null);
		//uri.append("include=abcdgef");
		
		if(context.getMinorVersion() == null)
		{
		context.setMinorVersion("37");
		}
		
		uri.append("minorversion").append("=").append(context.getMinorVersion()).append("&");
		if( context.getIncludeParam() !=null)
		{
		int includeval = context.getIncludeParam().size();
		String includeParam = "";
		if (includeval > 0)
		{
			for (int i=0; i<includeval; i++)
			{
				includeParam = includeParam + context.getIncludeParam().get(i) + ",";				
			}
			uri.append("include").append("=").append(includeParam.substring(0, includeParam.length()-1)).append("&");
		}
		}
		
		return uri.toString();
	}
528728
private void importQueue(
            final ITenant tenant,
            final Map<PortalDataKey, Set<BucketTuple>> queue,
            final StringBuilder importReport)
            throws Exception {

        final StandardEvaluationContext ctx = new StandardEvaluationContext();
        ctx.setRootObject(new RootObjectImpl(tenant));
        IDataTemplatingStrategy templating = new SpELDataTemplatingStrategy(portalSpELService, ctx);
        Document doc = null;
        try {
            for (PortalDataKey pdk : dataKeyImportOrder) {
                Set<BucketTuple> bucket = queue.get(pdk);
                if (bucket != null) {
                    log.debug(
                            "Importing the specified PortalDataKey tenant '{}':  {}",
                            tenant.getName(),
                            pdk.getName());
                    for (BucketTuple tuple : bucket) {
                        doc = tuple.getDocument();
                        Source data =
                                templating.processTemplates(
                                        doc, tuple.getResource().getURL().toString());
                        dataHandlerService.importData(data, pdk);
                        importReport.append(createImportReportLineItem(pdk, tuple));
                    }
                }
            }

        } catch (Exception e) {
            log.error(
                    "Failed to process the specified template document:\n{}",
                    (doc != null ? doc.asXML() : "null"),
                    e);
            throw e;
        }
    }
12075
@SuppressWarnings("unchecked")
  private void handleRequest(long requestId, Object request) {
    HandlerHolder holder = handlers.get(request.getClass());
    if (holder == null) {
      connection.handleResponseError(requestId, new ConnectException("no handler registered"));
      return;
    }

    Function<Object, CompletableFuture<Object>> handler = (Function<Object, CompletableFuture<Object>>) holder.handler;

    try {
      holder.context.executor().execute(() -> {
        if (open && connection.open) {
          CompletableFuture<Object> responseFuture = handler.apply(request);
          if (responseFuture != null) {
            responseFuture.whenComplete((response, error) -> {
              if (!open || !connection.open) {
                connection.handleResponseError(requestId, new ConnectException("connection closed"));
              } else if (error == null) {
                connection.handleResponseOk(requestId, response);
              } else {
                connection.handleResponseError(requestId, error);
              }
            });
          }
        } else {
          connection.handleResponseError(requestId, new ConnectException("connection closed"));
        }
      });
    } catch (RejectedExecutionException e) {
      connection.handleResponseError(requestId, new ConnectException("connection closed"));
    }
  }
337692
public final void redir(final Map<String, Object> pRqVs,
    final IRequestData pRqDt) throws Exception {
    String procNm = pRqDt.getParameter("nmPrcRed");
    IProcessor proc = this.procFac.lazyGet(pRqVs, procNm);
    proc.process(pRqVs, pRqDt);
  }
521452
public final void doWork(final HttpServletRequest pReq,
    final HttpServletResponse pResp) throws ServletException, IOException {
    pReq.setCharacterEncoding("UTF-8");
    pResp.setCharacterEncoding("UTF-8");
    try {
      HashMap<String, Object> reqVars = new HashMap<String, Object>();
      HttpRequestData requestData = new HttpRequestData(pReq, pResp);
      requestData.setAttribute("reqVars", reqVars);
      IHandlerRequest hndlI18nRequest = (IHandlerRequest) this
        .factoryAppBeans.lazyGet("hndlI18nRequest");
      hndlI18nRequest.handle(reqVars, requestData);
      String nmRnd = pReq.getParameter("nmRnd");
      if (this.defaultJsp != null && "index".equals(this.defaultJsp)) {
        //TODO extract into handler
        if (pReq.getParameter("logoff") != null) {
          pReq.getSession().invalidate();
        }
        @SuppressWarnings("rawtypes")
        SrvAddTheFirstUser srvAddFiU = (SrvAddTheFirstUser) getServletContext()
          .getAttribute("srvAddTheFirstUser");
        if (srvAddFiU != null && !srvAddFiU.checkIsThereAnyUser()) {
          nmRnd = "addFirstUser";
        }
      }
      if (nmRnd == null) {
        nmRnd = this.defaultJsp;
      }
      if (this.handlerName != null) {
        IHandlerRequest handleRequest = (IHandlerRequest) this
          .factoryAppBeans.lazyGet(this.handlerName);
        handleRequest.handle(reqVars, requestData);
      }
      ISrvI18n srvI18n = (ISrvI18n) this.factoryAppBeans.lazyGet("ISrvI18n");
      UtlJsp utlJsp = (UtlJsp) this.factoryAppBeans.lazyGet("UtlJsp");
      pReq.setAttribute("srvI18n", srvI18n);
      pReq.setAttribute("utlJsp", utlJsp);
      //renderer maybe overridden:
      String nmRnRd = (String) pReq.getAttribute("nmRnd");
      if (nmRnRd != null) {
        nmRnd = nmRnRd;
      }
      //processor can set redirect servlet, e.g. transactional to non-one:
      String srvlRd = (String) pReq.getAttribute("srvlRed");
      if (srvlRd != null) {
        RequestDispatcher rd = getServletContext().getRequestDispatcher(srvlRd);
        rd.forward(pReq, pResp);
      } else {
        String path = dirJsp + nmRnd + ".jsp";
        RequestDispatcher rd = getServletContext().getRequestDispatcher(path);
        rd.include(pReq, pResp);
      }
    } catch (Exception e) {
      if (this.factoryAppBeans != null) {
        ILog logger = null;
        try {
          logger = (ILog) this.factoryAppBeans.lazyGet("ILog");
          logger.error(null, getClass(), "WORK", e);
        } catch (Exception e1) {
          e1.printStackTrace();
          e.printStackTrace();
        }
      } else {
        e.printStackTrace();
      }
      if (e instanceof ExceptionWithCode) {
        pReq.setAttribute("error_code",
          ((ExceptionWithCode) e).getCode());
        pReq.setAttribute("short_message",
          ((ExceptionWithCode) e).getShortMessage());
      } else {
        pReq.setAttribute("error_code",
          HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
      }
      pReq.setAttribute("javax.servlet.error.status_code",
        HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
      pReq.setAttribute("javax.servlet.error.exception", e);
      pReq.setAttribute("javax.servlet.error.request_uri",
        pReq.getRequestURI());
      pReq.setAttribute("javax.servlet.error.servlet_name", this.getClass()
        .getCanonicalName());
      pResp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
  }
277224
public void execute() throws IOException {
        // collect types
        try {
            collectTypes();
        } catch (Exception e) {
            throw new QueryException(e);
        }

        // go through supertypes
        Set<Supertype> additions = Sets.newHashSet();
        for (Map.Entry<Class<?>, EntityType> entry : allTypes.entrySet()) {
            EntityType entityType = entry.getValue();
            if (entityType.getSuperType() != null && !allTypes.containsKey(entityType.getSuperType().getType().getJavaClass())) {
                additions.add(entityType.getSuperType());
            }
        }

        for (Supertype type : additions) {
            type.setEntityType(createEntityType(type.getType(), this.superTypes));
        }

        // merge supertype fields into subtypes
        Set<EntityType> handled = new HashSet<EntityType>();
        for (EntityType type : superTypes.values()) {
            addSupertypeFields(type, allTypes, handled);
        }
        for (EntityType type : entityTypes.values()) {
            addSupertypeFields(type, allTypes, handled);
        }
        for (EntityType type : embeddableTypes.values()) {
            addSupertypeFields(type, allTypes, handled);
        }

        // serialize them
        serialize(superTypes, supertypeSerializer);
        serialize(embeddableTypes, embeddableSerializer);
        serialize(entityTypes, entitySerializer);
    }