Package org.openbravo.service.web

Examples of org.openbravo.service.web.ResourceNotFoundException


            final String insertFlag = request.getParameter("insertFlag");

            try {
                ModelProvider.getInstance().getEntity(entityName);
            } catch (final CheckException ce) {
                throw new ResourceNotFoundException("Resource " + entityName
                        + " not found", ce);
            }

            // Where clause
            final String where = request.getParameter("where");
View Full Code Here


        final Map<String, String> productIDandPriceSell = new HashMap<String, String>();
        // Get PriceList with priceListID
        final BaseOBObject bobo = OBDal.getInstance().get(entityName,
                priceListID);
        if (bobo == null) {
            throw new ResourceNotFoundException("No resource found for entity "
                    + entityName + " using id " + priceListID);
        }
        // Get PriceListVersions of the PriceList with priceListID
        final List<PriceListVersion> pricelvl = (List<PriceListVersion>) bobo
                .get("pricingPriceListVersionList");
View Full Code Here

      final String entityName = segment;

      try {
        ModelProvider.getInstance().getEntity(entityName);
      } catch (final CheckException ce) {
        throw new ResourceNotFoundException("Resource " + entityName + " not found", ce);
      }

      // now check the second segment and see if an operation is required
      String id = null;
      boolean countOperation = false;
      if (segments.length == 2) {
        if (segments[1].equals("count")) {
          countOperation = true;
        } else {
          id = segments[1];
        }
      }

      if (id == null) {
        // show all of type entityname

        // check if there is a whereClause
        final String where = request.getParameter("where");
        final String orderBy = request.getParameter("orderBy");
        final String firstResult = request.getParameter("firstResult");
        final String maxResult = request.getParameter("maxResult");

        String whereOrderByClause = "";
        if (where != null) {
          whereOrderByClause += where;
        }
        if (orderBy != null && !countOperation) {
          whereOrderByClause += " order by " + orderBy;
        }

        final OBQuery<BaseOBObject> obq = OBDal.getInstance().createQuery(entityName,
            whereOrderByClause);

        if (firstResult != null) {
          try {
            obq.setFirstResult(Integer.parseInt(firstResult));
          } catch (NumberFormatException e) {
            throw new InvalidRequestException("Value of firstResult parameter is not an integer: "
                + firstResult);
          }
        }
        if (maxResult != null) {
          try {
            obq.setMaxResult(Integer.parseInt(maxResult));
          } catch (NumberFormatException e) {
            throw new InvalidRequestException("Value of maxResult parameter is not an integer: "
                + firstResult);
          }
        }

        if (countOperation) {
          response.setContentType("text/xml;charset=UTF-8");
          final String xmlResult = WebServiceUtil.getInstance().createResultXML("" + obq.count());
          final Writer w = response.getWriter();
          w.write(xmlResult);
          w.close();
          return;
        } else {
          final StringWriter sw = new StringWriter();
          final EntityXMLConverter exc = EntityXMLConverter.newInstance();
          exc.setOptionEmbedChildren(true);
          exc.setOptionIncludeChildren(true);
          exc.setOptionIncludeReferenced(false);
          exc.setOptionExportClientOrganizationReferences(true);
          exc.setOutput(sw);
          exc.process(obq.list());
          xml = sw.toString();
        }
      } else {
        final BaseOBObject result = OBDal.getInstance().get(entityName, id);
        if (result == null) {
          throw new ResourceNotFoundException("No resource found for entity " + entityName
              + " using id " + id);
        }
        final StringWriter sw = new StringWriter();
        final EntityXMLConverter exc = EntityXMLConverter.newInstance();
        exc.setOptionEmbedChildren(true);
View Full Code Here

TOP

Related Classes of org.openbravo.service.web.ResourceNotFoundException

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.