Examples of JDCConnection


Examples of com.knowgate.jdc.JDCConnection

  public void doPost(HttpServletRequest request, HttpServletResponse response)
     throws IOException, ServletException {

     DBBind oBnd = null;
     JDCConnection oCon = null;

     short iAuth;
     boolean bAllowed;
     String sDbb = request.getParameter("profile");
     String sUsr = request.getParameter("user");
     String sPwd = request.getParameter("password");
     String sCmd = request.getParameter("command");
     String sCls = request.getParameter("class");
     String sTbl = request.getParameter("table");
     String sFld = request.getParameter("fields");
     String sWhr = request.getParameter("where");
     String sMax = request.getParameter("maxrows");
     String sSkp = request.getParameter("skip");
     String sCol = request.getParameter("coldelim");
     String sRow = request.getParameter("rowdelim");

     if (DebugFile.trace) {
       DebugFile.writeln("Begin HttpDataObjsServlet.doPost()");
       DebugFile.incIdent();
     }

     if (null==sDbb) {
       sDbb = "hipergate";
     }
     if (null==sUsr) {
       if (DebugFile.trace) DebugFile.decIdent();
       response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter user is requiered");
       return;
     }
     if (null==sPwd) {
       if (DebugFile.trace) DebugFile.decIdent();
       response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter password is requiered");
       return;
     }
     if (null==sCmd) {
       if (DebugFile.trace) DebugFile.decIdent();
       response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter command is requiered");
       return;
     } else if (sCmd.equalsIgnoreCase("query")) {
       if (null==sFld) {
         if (DebugFile.trace) DebugFile.decIdent();
         response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter fields is requiered");
         return;
       } else if (hasSqlSignature(sFld)) {
         if (DebugFile.trace) DebugFile.decIdent();
         response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter fields has an invalid syntax");
         return;
       }
     }
     if (null==sTbl) {
       if (DebugFile.trace) DebugFile.decIdent();
       response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter table is requiered");
       return;
     } else if (hasSqlSignature(sTbl)) {
       if (DebugFile.trace) DebugFile.decIdent();
       response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter table has an invalid syntax");
       return;
     }

     Properties oEnv = Environment.getProfile(sDbb);

     if (null==oEnv) {
       if (DebugFile.trace) DebugFile.decIdent();
       response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "Databind " + sDbb + " is not available");
       return;
     }

     if (!sCmd.equalsIgnoreCase("ping") && !sCmd.equalsIgnoreCase("query") && !sCmd.equalsIgnoreCase("update") && !sCmd.equalsIgnoreCase("nextval")) {
       if (DebugFile.trace) DebugFile.decIdent();
       response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "Command " + sCmd + " not recognized");
       return;
     }

     if (sCmd.equalsIgnoreCase("ping")) {
       response.setContentType("text/plain");
       response.getOutputStream().print("HttpDataObjsServlet ping OK");
       if (DebugFile.trace) {
         DebugFile.decIdent();
         DebugFile.writeln("End HttpDataObjsServlet.doPost()");
       }
       return;
     }

     if (oBindings.containsKey(sDbb)) {
       oBnd = (DBBind) oBindings.get(sDbb);
     } else {
       oBnd = new DBBind(sDbb);
       oBindings.put(sDbb, oBnd);
     }

     if (sCmd.equalsIgnoreCase("query")) {
       int iMax;
       if (null==sMax)
         iMax = 500;
       else
         iMax = Integer.parseInt(sMax);
       int iSkp;
       if (null==sSkp)
         iSkp = 0;
       else
         iSkp = Integer.parseInt(sSkp);
       DBSubset oDbs = new DBSubset (sTbl, sFld, sWhr, iMax);
       if (null!=sRow) oDbs.setRowDelimiter(sRow);
       if (null!=sCol) oDbs.setColumnDelimiter(sCol);
       oDbs.setMaxRows(iMax);
       try {
         oCon = oBnd.getConnection("HttpDataObjsServlet");
         if (null==oCon) {
           if (DebugFile.trace) DebugFile.decIdent();
           throw new ServletException("ERROR Unable to get database connection from pool "+sDbb);
         }
         if (oBnd.exists(oCon, DB.k_users, "U")) {
           if (Gadgets.checkEMail(sUsr)) {
             sUsr = ACLUser.getIdFromEmail(oCon, sUsr);
             if (null==sUsr)
               iAuth = ACL.USER_NOT_FOUND;
             else
               iAuth = ACL.autenticate(oCon, sUsr, sPwd, ACL.PWD_CLEAR_TEXT);
           } else {
             iAuth = ACL.autenticate(oCon, sUsr, sPwd, ACL.PWD_CLEAR_TEXT);
           }
         } else {
           iAuth = 0;
         } // fi (exists k_users)
         if (iAuth<0) {
           response.sendError(HttpServletResponse.SC_FORBIDDEN, ACL.getErrorMessage(iAuth));
         } else {
           oDbs.load(oCon, iSkp);
           response.setContentType("text/plain");
           response.setCharacterEncoding("UTF-8");
           response.getOutputStream().write(oDbs.toString().getBytes("UTF-8"));             
         }
         oCon.close("HttpDataObjsServlet");
         oCon = null;
       } catch (SQLException sqle) {
         if (null!=oCon) {
           try { oCon.close("HttpDataObjsServlet"); } catch (Exception ignore) {}
           oCon = null;
         }
         if (DebugFile.trace) DebugFile.decIdent();
         throw new ServletException("SQLException "+sqle.getMessage());
       }
     }
     else if (sCmd.equalsIgnoreCase("update")) {
       if (DebugFile.trace) DebugFile.writeln("command is update");
       Enumeration oParamNames = request.getParameterNames();
       DBPersist oDbp;
       Class oCls;

       if (null==sCls) {
         oDbp = new DBPersist(sTbl, "DBPersist");
         try {
           oCls = Class.forName("com.knowgate.dataobjs.DBPersist");
         } catch (ClassNotFoundException neverthrown) { oCls=null; }

       } else {
         try {
           oCls = Class.forName(sCls);
           oDbp = (DBPersist) oCls.newInstance();
         } catch (ClassNotFoundException nfe) {
           if (DebugFile.trace) DebugFile.decIdent();
           throw new ServletException("ClassNotFoundException "+nfe.getMessage()+" "+sCls);
         } catch (InstantiationException ine) {
           if (DebugFile.trace) DebugFile.decIdent();
           throw new ServletException("InstantiationException "+ine.getMessage()+" "+sCls);
         } catch (IllegalAccessException iae) {
           if (DebugFile.trace) DebugFile.decIdent();
           throw new ServletException("IllegalAccessException "+iae.getMessage()+" "+sCls);
         } catch (ClassCastException cce) {
           if (DebugFile.trace) DebugFile.decIdent();
           throw new ServletException("ClassCastException "+cce.getMessage()+" "+sCls);
         }

         if (sCls.equals("com.knowgate.hipergate.InvoicePayment") &&
            request.getParameter("gu_invoice")!=null & request.getParameter("pg_payment")!=null) {
           if (request.getParameter("gu_invoice").length()>0 &&
               request.getParameter("pg_payment").length()>0) {
             try {
               oCon = oBnd.getConnection("HttpDataObjsServlet.InvoicePayment", true);
               oDbp.load(oCon, new Object[]{request.getParameter("gu_invoice"), new Integer(request.getParameter("pg_payment"))});
               oCon.close("HttpDataObjsServlet.InvoicePayment");
               oCon=null;
             } catch (Exception xcpt) {
               if (DebugFile.trace) {
                  DebugFile.writeln(xcpt.getClass().getName()+" "+xcpt.getMessage());
                 DebugFile.decIdent();
               }
               throw new ServletException(xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
             }
             finally {
               if (oCon!=null) { try { if (!oCon.isClosed()) { oCon.close("HttpDataObjsServlet.InvoicePayment"); } } catch (Exception ignore) { } }
             } // finally
           } // fi (gu_invoice && pg_payment)
         } // fi (sCls==InvoicePayment)
       } // fi

       if (DebugFile.trace) DebugFile.writeln("class "+oDbp.getClass().getName()+" instantiated");

       while (oParamNames.hasMoreElements()) {
         String sKey = (String) oParamNames.nextElement();
         if (DebugFile.trace) DebugFile.writeln("reading parameter "+sKey);
         sKey = sKey.trim();
         int iSpc = sKey.indexOf(' ');
         if (iSpc>0) {
           String sKeyName = sKey.substring(0, iSpc);
           iSpc++;
           if (iSpc<sKey.length()-1) {
             String sSQLType = sKey.substring(iSpc);
             if (DebugFile.trace) DebugFile.writeln("sqltype is "+sSQLType);
             if (sSQLType.toUpperCase().startsWith("DATE") || sSQLType.toUpperCase().startsWith("DATETIME") || sSQLType.toUpperCase().startsWith("TIMESTAMP")) {
               iSpc = sSQLType.indexOf(' ');
               String sDtFmt = "";
               try {
                 if (iSpc > 0) {
                   sDtFmt = sSQLType.substring(++iSpc);
                   if (DebugFile.trace) DebugFile.writeln("date format is "+sDtFmt);
                   oDbp.replace(sKeyName, request.getParameter(sKey), new SimpleDateFormat(sDtFmt));
                 } else {
                   oDbp.replace(sKeyName, request.getParameter(sKey), DBColumn.getSQLType(sSQLType));
                 }
               } catch (ParseException pe) {
                 if (DebugFile.trace) DebugFile.decIdent();
                 throw new ServletException("ERROR ParseException "+sKey+"|"+sDtFmt+"|"+request.getParameter(sKey)+" "+pe.getMessage());
               } catch (IllegalArgumentException ia) {
                 if (DebugFile.trace) DebugFile.decIdent();
                 throw new ServletException("ERROR IllegalArgumentException "+sKey+"|"+sDtFmt+"|"+request.getParameter(sKey)+ia.getMessage());
               }
             } else {
               try {
                 oDbp.replace(sKeyName, request.getParameter(sKey), DBColumn.getSQLType(sSQLType));
               } catch (NumberFormatException nfe) {
                 if (DebugFile.trace) DebugFile.decIdent();
                 throw new ServletException("ERROR NumberFormatException "+sKey+" "+" "+request.getParameter(sKey)+" "+nfe.getMessage());
               }
             }
           } else {
             oDbp.replace(sKeyName, request.getParameter(sKey));
           }
         } else {
           oDbp.replace(sKey, request.getParameter(sKey));
         }
       } // wend
       try {
         oCon = oBnd.getConnection("HttpDataObjsServlet");
         if (null==oCon) {
           if (DebugFile.trace) DebugFile.decIdent();
           throw new ServletException("ERROR Unable to get database connection from pool "+sDbb);
         }
         if (oBnd.exists(oCon, DB.k_users, "U")) {
           if (Gadgets.checkEMail(sUsr)) {
             sUsr = ACLUser.getIdFromEmail(oCon, sUsr);
             if (null==sUsr)
               iAuth = ACL.USER_NOT_FOUND;
             else
               iAuth = ACL.autenticate(oCon, sUsr, sPwd, ACL.PWD_CLEAR_TEXT);
           } else {
               iAuth = ACL.autenticate(oCon, sUsr, sPwd, ACL.PWD_CLEAR_TEXT);
           } // fi (checkEMail(sUsr))
         } else {
           iAuth = 0;
         } // fi (exists(DBk_users))
         if (iAuth<0) {
           response.sendError(HttpServletResponse.SC_FORBIDDEN, ACL.getErrorMessage(iAuth));
         } else {
           if (oDbp.isNull(DB.gu_workarea))
             bAllowed = true;
           else
             bAllowed = isUserAllowed(oCon, sUsr, oDbp.getString(DB.gu_workarea));
           if (bAllowed) {
               oCon.setAutoCommit(true);
               if (null==sCls) {
                 oDbp.store(oCon);
               } else {
                 if (DebugFile.trace) DebugFile.writeln(oCls.getName()+".getMethod(\"store\", new Class[]{Class.forName(\"com.knowgate.jdc.JDCConnection\")}).invoke(...)");
                 oCls.getMethod("store", new Class[]{Class.forName("com.knowgate.jdc.JDCConnection")}).invoke(oDbp, new Object[]{oCon});
               } // fi (sCls)
               response.setContentType("text/plain");
               response.setCharacterEncoding("UTF-8");
               response.getOutputStream().print("SUCCESS");
           } else {
               response.sendError(HttpServletResponse.SC_FORBIDDEN, "User does not have write permissions on target WorkArea");
           } // fi (bAllowed)
         }
         oCon.close("HttpDataObjsServlet");
         oCon = null;
       } catch (InvocationTargetException ite) {
         if (null!=oCon) {
           try { oCon.close("HttpDataObjsServlet"); oCon = null;
           } catch (Exception ignore) {}
         } // fi
         if (DebugFile.trace) DebugFile.decIdent();
         throw new ServletException(ite.getCause().getClass().getName()+" "+ite.getCause().getMessage()+"\n"+StackTraceUtil.getStackTrace(ite));
       } catch (Exception xcpt) {
         if (null!=oCon) {
           try { oCon.close("HttpDataObjsServlet"); oCon = null;
           } catch (Exception ignore) {}
         } // fi
         if (DebugFile.trace) DebugFile.decIdent();
         throw new ServletException(xcpt.getClass().getName()+" "+xcpt.getMessage()+"\n"+StackTraceUtil.getStackTrace(xcpt));
       }
     }
     else if (sCmd.equalsIgnoreCase("nextval")) {

       try {
         oCon = oBnd.getConnection("HttpDataObjsServlet");
         if (null==oCon) {
           if (DebugFile.trace) DebugFile.decIdent();
           throw new ServletException("ERROR Unable to get database connection from pool "+sDbb);
         }
         if (oBnd.exists(oCon, DB.k_users, "U")) {
           if (Gadgets.checkEMail(sUsr)) {
             sUsr = ACLUser.getIdFromEmail(oCon, sUsr);
             if (null==sUsr)
               iAuth = ACL.USER_NOT_FOUND;
             else
               iAuth = ACL.autenticate(oCon, sUsr, sPwd, ACL.PWD_CLEAR_TEXT);
           } else {
             iAuth = ACL.autenticate(oCon, sUsr, sPwd, ACL.PWD_CLEAR_TEXT);
           }
         } else {
           iAuth = 0;
         } // fi (exists k_users)
         switch (iAuth) {
             case ACL.ACCOUNT_CANCELLED:
               response.sendError(HttpServletResponse.SC_FORBIDDEN, "Account cancelled");
               break;
             case ACL.ACCOUNT_DEACTIVATED:
               response.sendError(HttpServletResponse.SC_FORBIDDEN, "Account deactivated");
               break;
             case ACL.INVALID_PASSWORD:
               response.sendError(HttpServletResponse.SC_FORBIDDEN, "Invalid password");
               break;
             case ACL.PASSWORD_EXPIRED:
               response.sendError(HttpServletResponse.SC_FORBIDDEN, "Password expired");
               break;
             case ACL.USER_NOT_FOUND:
               response.sendError(HttpServletResponse.SC_FORBIDDEN, "User not found");
               break;
             default:
               String sNextVal = String.valueOf(oBnd.nextVal(oCon, sTbl));
               response.setContentType("text/plain");
               response.setCharacterEncoding("ISO-8859-1");
               response.getOutputStream().write(sNextVal.getBytes("ISO8859_1"));
         } // end switch
         oCon.close("HttpDataObjsServlet");
         oCon = null;
       } catch (SQLException sqle) {
         if (null!=oCon) {
           try { oCon.close("HttpDataObjsServlet"); } catch (Exception ignore) {}
           oCon = null;
         }
         if (DebugFile.trace) DebugFile.decIdent();
         throw new ServletException("SQLException "+sqle.getMessage());
       }      
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

   * @since 3.0
   */

  public static int currVal(Connection oSQLConn, String sSequenceName)
      throws SQLException, UnsupportedOperationException {
    return currVal(new JDCConnection(oSQLConn, null), sSequenceName);
  }
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

   */

  public static int nextVal(Connection oSQLConn, String sSequenceName)
      throws SQLException, UnsupportedOperationException {

    return nextVal(new JDCConnection(oSQLConn, null), sSequenceName);
  }
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

   * @return An open connection to the database.
   * @throws SQLException
   */

  public synchronized JDCConnection getConnection(String sCaller) throws SQLException {
    JDCConnection oConn;

    if (DebugFile.trace) {
      DebugFile.writeln("Begin DBBind.getConnection(" + sCaller + ")");
      DebugFile.incIdent();
    }

    if (null!=oConnectXcpt) {

        if (DebugFile.trace) {
          DebugFile.writeln(oConnectXcpt.getClass().getName()+" "+oConnectXcpt.getMessage());
          if (oConnectXcpt.getCause()!=null) {
            DebugFile.writeln(oConnectXcpt.getCause().getClass().getName()+" "+oConnectXcpt.getCause().getMessage());
          } // fi
          DebugFile.decIdent();
        } // fi

      if (oConnectXcpt instanceof SQLException) {
        throw (SQLException) oConnectXcpt;

      } else {
        throw new SQLException(oConnectXcpt.getClass().getName()+" "+oConnectXcpt.getMessage(), oConnectXcpt.getCause());
      }
    }

    if (null!=oConnPool) {
      oConn = oConnPool.getConnection(sCaller);
    }
    else {
      if (DebugFile.trace) DebugFile.writeln("ERROR: connection pool not set");
      oConn = null;
    }

    if (DebugFile.trace) {
      if (oConn!=null) DebugFile.writeln("Connection process id. is " + oConn.pid());
      DebugFile.decIdent();
      DebugFile.writeln("End DBBind.getConnection(" + sCaller + ") : " + (null==oConn ? "null" : "[Connection]") );
    }

    return oConn;
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

   * @since 5.0
   */

  public synchronized JDCConnection getConnection(String sCaller, boolean bReadOnly)
    throws SQLException {
    JDCConnection oConn = getConnection(sCaller);
  if (null!=oConn) oConn.setReadOnly(bReadOnly);
    return oConn;
  } // getConnection()
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

    if (DebugFile.trace) {
      DebugFile.decIdent();
      DebugFile.writeln("End DBBind.getConnection() : " + (null==oConn ? "null" : "[Connection]") );
    }

  return (Connection) new JDCConnection(oConn, null);
  } // getConnection()
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

              DebugFile.writeln("HttpSchedulerServlet.doGet(abort) : " + xcpt.getClass().getName() + " " + xcpt.getMessage());
              writeXML(response, "<scheduler><error><![CDATA["+xcpt.getClass().getName()+" "+xcpt.getMessage()+"]]></error></scheduler>");
          }
        } else {
          oDbj = new DBBind(Gadgets.substrUpTo(sProfile.substring(sProfile.lastIndexOf(File.separator)+1),0,'.'));
      JDCConnection oCon = null;
      try {
        oCon = oDbj.getConnection("SchedulerDaemon");
            Job.instantiate(oCon, sId, oDbj.getProperties()).abort(oCon);
            oCon.close("SchedulerDaemon");
            oCon=null;
      } catch (Exception xcpt) {
              DebugFile.writeln("HttpSchedulerServlet.doGet(abort) : " + xcpt.getClass().getName() + " " + xcpt.getMessage());
              writeXML(response, "<scheduler><error><![CDATA["+xcpt.getClass().getName()+" "+xcpt.getMessage()+"]]></error></scheduler>");
      } finally {
        try {
              if (null!=oCon) if (!oCon.isClosed()) oCon.close("SchedulerDaemon");
              oDbj.close();
        } catch (SQLException ignore) { }
      }                   
        } // fi
      } // fi
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

    try {
      if (DebugFile.trace)
        DebugFile.writeln("DriverManager.getConnection("+dburl+", "+dbusr+", ...)");

      if (schema.length()>0)
        oConn = new JDCConnection(DriverManager.getConnection(dburl, dbusr, dbpwd), null, schema);
      else
        oConn = new JDCConnection(DriverManager.getConnection(dburl, dbusr, dbpwd), null);

      short iAuth = ACL.autenticate(oConn, user, password, ACL.PWD_CLEAR_TEXT);

      if (iAuth<0) {
        oConn.close();
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

  public String render(RenderRequest req, String sEncoding)
    throws PortletException, IOException, IllegalStateException {

    DBBind dbb;
    DBSubset dbs, img;
    JDCConnection con = null;
    ByteArrayInputStream oInStream;
    ByteArrayOutputStream oOutStream;
    String sOutput, sCategoryId, sTemplatePath, sLimit, sOffset, sWrkArGet, sWorkAreaId, sImagePath;
    int iOffset=0, iLimit=2147483647, iProdCount=0, iImgCount=0;

    if (DebugFile.trace) {
      DebugFile.writeln("Begin ProductList.render()");
      DebugFile.incIdent();
    }

    sOffset = req.getParameter("offset");
    sLimit = req.getParameter("limit");

    sCategoryId = (String) req.getAttribute("category");
    sTemplatePath = (String) req.getAttribute("template");

    sWorkAreaId = req.getProperty("workarea");
    sWrkArGet = req.getProperty("workareasget");

    if (DebugFile.trace) {
      DebugFile.writeln("template=" + sTemplatePath);
      DebugFile.writeln("category=" + sCategoryId);
      DebugFile.writeln("workarea=" + sWorkAreaId);
      DebugFile.writeln("workareasget=" + sWrkArGet);
    }

    try {
      if (null!=sOffset)
        iOffset = Integer.parseInt(sOffset);
    } catch (java.lang.NumberFormatException nfe) {
        if (DebugFile.trace) DebugFile.decIdent();
        throw new PortletException("NumberFormatException parameter offset is not a valid integer value", nfe);
    }

    try {
      if (null!=sLimit)
        iLimit = Integer.parseInt(sLimit);
    } catch (java.lang.NumberFormatException nfe) {
        if (DebugFile.trace) DebugFile.decIdent();
        throw new PortletException("NumberFormatException parameter limit is not a valid integer value", nfe);
    }

    try {
      dbb = (DBBind) getPortletContext().getAttribute("GlobalDBBind");

      dbs = new DBSubset (DB.k_products + " p," + DB.k_x_cat_objs + " x",
                          "p." + DB.gu_product + ",p." + DB.nm_product + ",p." + DB.de_product +
                          ",p." + DB.pr_list + ",p." + DB.pr_sale + ",p." + DB.id_currency +
                          ",p." + DB.pct_tax_rate + ",p." + DB.is_tax_included +
                          ",p." + DB.dt_start + ",p." + DB.dt_end + ",p." + DB.tag_product + ",p." + DB.id_ref,
                          "p." + DB.gu_product + "=x." + DB.gu_object + " AND x." + DB.id_class + "=15 AND x." + DB.gu_category + "=? ORDER BY x." + DB.od_position, 20);

      con = dbb.getConnection("ProductList");

      if (null!=sLimit) dbs.setMaxRows(iLimit);

      if (sOffset==null)
        iProdCount = dbs.load(con, new Object[]{sCategoryId});
      else
        iProdCount = dbs.load(con, new Object[]{sCategoryId}, iOffset);

    }
    catch (SQLException sqle) {
      if (DebugFile.trace) DebugFile.writeln("SQLException " + sqle.getMessage());
      if (con!=null) {
        try { if (!con.isClosed()) con.close("ProductList"); } catch (SQLException ignore) { }
      }
      if (DebugFile.trace) DebugFile.decIdent();
      throw new PortletException("SQLException " + sqle.getMessage(), sqle);
    }

    if (DebugFile.trace) DebugFile.writeln(String.valueOf(iProdCount) + " products found");

    StringBuffer oXML = new StringBuffer(8192);

    oXML.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-stylesheet type=\"text/xsl\"?>\n<products count=\"" + String.valueOf(iProdCount) + "\">\n");

    Product oCurrentProd = new Product();

    for (int c=0; c<iProdCount; c++) {
      oXML.append("  <product>");
      oXML.append("<gu_product>"+dbs.getString(0,c)+"</gu_product><nm_product>"+dbs.getString(1,c)+"</nm_product><tr_product><![CDATA["+dbs.getStringNull(2,c,"")+"]]></tr_product><de_product><![CDATA["+dbs.getStringNull(3,c,"")+"]]></de_product>");

      oCurrentProd.replace(DB.gu_product, dbs.getString(0,c));

      oXML.append("<images>");

      try {
        img = oCurrentProd.getImages(con);
        iImgCount = img.getRowCount();

        for (int i=0; i<iImgCount; i++) {
          oXML.append("<image tp=\"" + img.getString(DB.tp_image,i) + "\"><gu_image>"+img.getString(DB.gu_image,i)+"</gu_image>");

          sImagePath = img.getString(DB.path_image,i);

          oXML.append("<src_image><![CDATA["+sWrkArGet+"/"+sWorkAreaId+"/apps/Shop/"+sImagePath.substring(sImagePath.indexOf(sWorkAreaId)+43)+"]]></src_image>");

          oXML.append("<nm_image><![CDATA["+img.getStringNull(DB.nm_image,i,"")+"]]></nm_image>");
          if (img.isNull(DB.dm_width,i)) oXML.append("<dm_width></dm_width>"); else oXML.append("<dm_width>" + img.get(DB.dm_width,i).toString() + "</dm_width>");
          if (img.isNull(DB.dm_height,i)) oXML.append("<dm_height></dm_height>"); else oXML.append("<dm_height>" + img.get(DB.dm_height,i).toString() + "</dm_height>");
          oXML.append("<tl_image>" + img.getStringNull(DB.tl_image,i,"") + "</tl_image></image>");
        } // next (i)
      }
      catch (SQLException sqle) { }
      catch (NullPointerException npe) { }

      oXML.append("</images></product>\n");
    } // next (c)

    try {
      con.close("ProductList");
      con = null;
    }
    catch (SQLException sqle) {
      if (DebugFile.trace) DebugFile.writeln("SQLException " + sqle.getMessage());
    }
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

      String sXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><?xml-stylesheet type=\"text/xsl\"?>\n<folder account=\""+(null==sMailAccount ? "" : sMailAccount)+"\" name=\"inbox\">";
   
      if (req.getWindowState().equals(WindowState.MINIMIZED) || null==sMailAccount) {
        sXML += "<messages total=\"0\" skip=\"0\"/></folder>";
      } else {
        JDCConnection oCon = null;
        try {
       
        SessionHandler oHnr;

          DBBind oDBB = (DBBind) getPortletContext().getAttribute("GlobalDBBind");
       
        oCon = oDBB.getConnection("NewMail");
       
        MailAccount oMacc = new MailAccount(oCon, sMailAccount);
       
        if (oMacc.load(oCon, sMailAccount))
          oHnr = new SessionHandler(oMacc);
      else
        oHnr = null;

      oCon.close("NewMail");
      oCon=null;
     
      if (null!=oHnr) {
        String[] aRecentXML = oHnr.listRecentMessages("INBOX", iMaxNew);
          if (null!=aRecentXML) {
          int nRecentXML = aRecentXML.length;
          sXML += "<messages total=\""+String.valueOf(nRecentXML)+"\" skip=\"0\">";
          for (int r=0; r<nRecentXML; r++)
              sXML += aRecentXML[r];
            sXML += "</messages>";
          } else {
            sXML += "<messages total=\"0\" skip=\"0\"/>";
          }// fi
      } else {
         if (DebugFile.trace) {
             DebugFile.writeln("Mail Account "+sMailAccount+" not found");
         }
          sXML += "<messages total=\"0\" skip=\"0\" />";
      }
        } catch (SQLException sqle) {
          if (oCon!=null) { try { oCon.close("NewMail"); oCon=null; } catch (SQLException ignore) {} }
          throw new PortletException(sqle.getMessage(), sqle);
        } catch (AuthenticationFailedException afe) {
          if (oCon!=null) { try { oCon.close("NewMail"); oCon=null; } catch (SQLException ignore) {} }
          throw new PortletException(afe.getMessage(), afe);
        } catch (NoSuchProviderException nspe) {
          if (oCon!=null) { try { oCon.close("NewMail"); oCon=null; } catch (SQLException ignore) {} }
          throw new PortletException(nspe.getMessage(), nspe);
        } catch (MessagingException jmme) {
          if (oCon!=null) { try { oCon.close("NewMail"); oCon=null; } catch (SQLException ignore) {} }
          throw new PortletException(jmme.getMessage(), jmme);
        }
        sXML += "</folder>";
      } // fi
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.