Example usage for org.json.simple.parser ParseException printStackTrace

List of usage examples for org.json.simple.parser ParseException printStackTrace

Introduction

In this page you can find the example usage for org.json.simple.parser ParseException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:net.swas.explorer.servlet.ms.CheckMSStatus.java

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 *///from w  w w  .j a  v a 2  s  .  c o  m
@SuppressWarnings("unchecked")
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    JSONObject messageJson = new JSONObject();
    messageJson.put("action", "status");
    this.prod.send(messageJson.toJSONString());

    if (FormFieldValidator.isLogin(request.getSession())) {

    } else {

    }
    String revMsg = this.cons.getReceivedMessage(request.getServletContext());
    log.info("Received Message :" + revMsg);
    if (revMsg != null) {

        JSONParser parser = new JSONParser();
        JSONObject revJson = null;
        try {

            revJson = (JSONObject) parser.parse(revMsg);
            String reqStatus = (String) revJson.get("status");

            if (reqStatus.equals("0")) {

                String msStatus = (String) revJson.get("msStatus");
                if (msStatus.trim().equals("1")) {
                    request.setAttribute("msStatus", "1");
                } else if (msStatus.trim().equals("0")) {
                    request.setAttribute("msStatus", "0");
                }

            }

        } catch (ParseException e) {

            e.printStackTrace();

        }

    }

    RequestDispatcher rd = request.getRequestDispatcher("/msStateUpdate.jsp");
    rd.forward(request, response);

}

From source file:net.swas.explorer.servlet.ms.DeployRuleGroup.java

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 *///from   w w  w. java2  s.c o  m
@SuppressWarnings("unchecked")
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String groupName = request.getParameter("groupName");
    String ruleFileString = "";
    String status = "", msg = "";

    PrintWriter out = response.getWriter();
    JSONObject respJson = new JSONObject();
    JSONObject messageJson = new JSONObject();

    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    if (FormFieldValidator.isLogin(request.getSession())) {
        //get the rule file string 
        List<Entity> ruleList = rulehandler.getRuleByGroup(groupName);

        for (Entity entity : ruleList) {
            log.info("Entity : " + entity.toString());

            Rule simpleRule = null;
            ChainRule chainRule = null;
            if (entity instanceof Rule) {
                simpleRule = (Rule) entity;
                ruleFileString += ModSecTranslator.getRuleString(simpleRule);
            } else if (entity instanceof ChainRule) {
                chainRule = (ChainRule) entity;
                ruleFileString += ModSecTranslator.getRuleString(chainRule);
            }
        }

        //produce message
        messageJson.put("action", "deployRules");
        messageJson.put("groupName", groupName);
        messageJson.put("ruleString", ruleFileString);
        this.prod.send(messageJson.toJSONString());

        //consume message 
        String revMsg = this.cons.getReceivedMessage(request.getServletContext());
        log.info("Received Message :" + revMsg);
        if (revMsg != null) {

            JSONParser parser = new JSONParser();
            JSONObject revJson = null;
            try {

                revJson = (JSONObject) parser.parse(revMsg);
                respJson = revJson;

            } catch (ParseException e) {

                status = "1";
                msg = "Unable to reach modsercurity service. Please try later";
                e.printStackTrace();

            }

        } else {

            status = "1";
            msg = "Unable to reach modsercurity service. Please try later";
            log.info(">>>>>>>>>   Message is not received......");

        }

        if (!status.equals("")) {

            respJson.put("status", status);
            respJson.put("message", msg);

        }
    } else {
        status = "2";
        msg = "User Session Expired";
        respJson.put("status", status);
        respJson.put("message", msg);
    }

    try {
        log.info("Sending Json : " + respJson.toString());
        out.print(respJson.toString());
    } finally {
        out.close();
    }

}

From source file:net.swas.explorer.servlet.ms.DeploySelectedRules.java

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 *///from w  w  w.  j a  v a 2s.c  o m
@SuppressWarnings("unchecked")
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String[] ruleIDs = request.getParameter("ruleID").split(",");
    String ruleFileString = "";
    String status = "", msg = "";

    PrintWriter out = response.getWriter();
    JSONObject respJson = new JSONObject();
    JSONObject messageJson = new JSONObject();

    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");

    if (FormFieldValidator.isLogin(request.getSession())) {
        //get the rule file string 
        for (String ruleID : ruleIDs) {

            log.info(" RuleID :  " + ruleID);
            if (ruleID.split("\\.")[0].equals("Rule")) {

                log.info("----------------->>>>> RULE");
                Rule rule = (Rule) rulehandler.get(ruleID.split("\\.")[1]);
                ruleFileString += ModSecTranslator.getRuleString(rule);

            } else {

                log.info("----------------->>>>> CHAIN RULE");
                ChainRule chainRule = (ChainRule) chRuleHandler.get(ruleID.split("\\.")[1]);
                ruleFileString += ModSecTranslator.getRuleString(chainRule);

            }

        }

        //produce message
        messageJson.put("action", "deployRules");
        messageJson.put("ruleString", ruleFileString);
        this.prod.send(messageJson.toJSONString());

        //consume message 
        String revMsg = this.cons.getReceivedMessage(request.getServletContext());
        log.info("Received Message :" + revMsg);
        if (revMsg != null) {

            JSONParser parser = new JSONParser();
            JSONObject revJson = null;
            try {

                revJson = (JSONObject) parser.parse(revMsg);
                respJson = revJson;

            } catch (ParseException e) {

                status = "1";
                msg = "Unable to reach modsercurity service. Please try later";
                e.printStackTrace();

            }

        } else {

            status = "1";
            msg = "Unable to reach modsercurity service. Please try later";
            log.info(">>>>>>>>>   Message is not received......");

        }

        if (!status.equals("")) {

            respJson.put("status", status);
            respJson.put("message", msg);

        }

    } else {
        status = "2";
        msg = "User Session Expired";
        respJson.put("status", status);
        respJson.put("message", msg);
    }

    try {
        log.info("Sending Json : " + respJson.toString());
        out.print(respJson.toString());
    } finally {
        out.close();
    }

}

From source file:net.swas.explorer.servlet.ms.GetMSConfig.java

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 *///  www . j a v a2s. co m
@SuppressWarnings("unchecked")
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    JSONObject messageJson = new JSONObject();

    messageJson.put("action", "readMSConfig");
    this.prod.send(messageJson.toJSONString());

    String revMsg = this.cons.getReceivedMessage(request.getServletContext());
    log.info("Received Message :" + revMsg);
    if (revMsg != null) {

        JSONParser parser = new JSONParser();
        JSONObject revJson = null;
        try {

            revJson = (JSONObject) parser.parse(revMsg);
            request.removeAttribute("msConfig");
            request.setAttribute("msConfig", revJson);

        } catch (ParseException e) {

            e.printStackTrace();

        }

    }

    RequestDispatcher rd = request.getRequestDispatcher("/msConfigForm.jsp");
    rd.forward(request, response);

}

From source file:net.swas.explorer.servlet.ms.GetMSStatus.java

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 *//*from  w  w  w  . j  av a2  s  . c o m*/
@SuppressWarnings("unchecked")
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String status = "", msg = "";

    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    PrintWriter out = response.getWriter();
    JSONObject messageJson = new JSONObject();
    JSONObject respJson = new JSONObject();

    messageJson.put("action", "status");
    this.prod.send(messageJson.toJSONString());

    String revMsg = this.cons.getReceivedMessage(request.getServletContext());

    if (FormFieldValidator.isLogin(request.getSession())) {
        log.info("Received Message :" + revMsg);
        if (revMsg != null) {

            JSONParser parser = new JSONParser();
            JSONObject revJson = null;
            try {

                revJson = (JSONObject) parser.parse(revMsg);
                respJson = revJson;

            } catch (ParseException e) {

                status = "1";
                msg = "Unable to reach modsercurity service. Please try later";
                e.printStackTrace();

            }

        } else {

            status = "1";
            msg = "Unable to reach modsercurity service. Please try later";
            log.info("Message is not received......");

        }

        if (!status.equals("")) {

            respJson.put("status", status);
            respJson.put("message", msg);

        }
    } else {
        status = "2";
        msg = "User Session Expired";
        respJson.put("status", status);
        respJson.put("message", msg);
    }

    try {
        log.info("Sending Json : " + respJson.toString());
        out.print(respJson.toString());
    } finally {
        out.close();
    }

}

From source file:net.swas.explorer.servlet.ms.MSStateUpdate.java

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 *//* w w w  . j  a v a 2s . com*/
@SuppressWarnings("unchecked")
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String action = request.getParameter("action");
    String status = "", msg = "";

    PrintWriter out = response.getWriter();
    JSONObject respJson = new JSONObject();
    JSONObject messageJson = new JSONObject();

    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");

    messageJson.put("action", action);
    this.prod.send(messageJson.toJSONString());

    if (FormFieldValidator.isLogin(request.getSession())) {

        String revMsg = this.cons.getReceivedMessage(request.getServletContext());
        log.info("Received Message :" + revMsg);
        if (revMsg != null) {

            JSONParser parser = new JSONParser();
            JSONObject revJson = null;
            try {

                revJson = (JSONObject) parser.parse(revMsg);
                respJson = revJson;

            } catch (ParseException e) {

                status = "1";
                msg = "Unable to reach modsercurity service. Please try later";
                e.printStackTrace();

            }

        } else {

            status = "1";
            msg = "Unable to reach modsercurity service. Please try later";
            log.info("Message is not received......");

        }

        if (!status.equals("")) {

            respJson.put("status", status);
            respJson.put("message", msg);

        }
    } else {
        status = "2";
        msg = "User Session Expired";
        respJson.put("status", status);
        respJson.put("message", msg);
    }

    try {
        log.info("Sending Json : " + respJson.toString());
        out.print(respJson.toString());
    } finally {
        out.close();
    }

}

From source file:net.swas.explorer.servlet.ms.WriteMSConfig.java

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 *//*from   w ww .  j  av a2s . co m*/
@SuppressWarnings("unchecked")
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    Map<String, String[]> params = request.getParameterMap();
    String status = "", msg = "";

    PrintWriter out = response.getWriter();
    JSONObject respJson = new JSONObject();
    JSONObject messageJson = new JSONObject();

    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");

    messageJson.put("action", "writeMSConfig");

    if (FormFieldValidator.isLogin(request.getSession())) {
        for (String key : params.keySet()) {

            if (params.get(key) == null) {
                messageJson.put(key, "");
            } else if (params.get(key)[0].equals("")) {
                messageJson.put(key, "");
            } else {
                messageJson.put(key, params.get(key)[0]);
            }

        }

        log.info("Sending Json : " + messageJson.toJSONString());
        this.prod.send(messageJson.toJSONString());

        String revMsg = this.cons.getReceivedMessage(request.getServletContext());
        log.info("Received Message :" + revMsg);
        if (revMsg != null) {

            JSONParser parser = new JSONParser();
            JSONObject revJson = null;
            try {

                revJson = (JSONObject) parser.parse(revMsg);
                respJson = revJson;

            } catch (ParseException e) {

                status = "1";
                msg = "Unable to reach modsercurity service. Please try later";
                e.printStackTrace();

            }

        } else {

            status = "1";
            msg = "Unable to reach modsercurity service. Please try later";
            log.info("Message is not received......");

        }

        if (!status.equals("")) {

            respJson.put("status", status);
            respJson.put("message", msg);

        }
    } else {
        status = "2";
        msg = "User Session Expired";
        respJson.put("status", status);
        respJson.put("message", msg);
    }

    try {
        log.info("Sending Json : " + respJson.toString());
        out.print(respJson.toString());
    } finally {
        out.close();
    }

}

From source file:nl.vumc.biomedbridges.galaxy.metadata.GalaxyWorkflowStep.java

/**
 * Fill the tool state map based on the values in the tool state json object.
 *
 * @param toolStateObject the tool state json object.
 *//*from  ww  w .ja  v  a 2  s . c o  m*/
private void fillToolState(final Object toolStateObject) {
    try {
        if (toolStateObject != null) {
            final JSONObject toolStateJson = (JSONObject) new JSONParser().parse(toolStateObject.toString());
            for (final Object parameterObject : toolStateJson.entrySet()) {
                final Map.Entry parameterEntry = (Map.Entry) parameterObject;
                final Object parameterValue = parameterEntry.getValue();
                final Object toolStateValue = parameterValue != null ? getToolStateValue(parameterValue) : null;
                logger.trace(parameterEntry.getKey() + " -> " + toolStateValue
                        + (toolStateValue != null ? " (" + toolStateValue.getClass().getName() + ")" : ""));
                this.toolState.put((String) parameterEntry.getKey(), toolStateValue);
            }
        }
    } catch (final ParseException e) {
        e.printStackTrace();
    }
}

From source file:org.alfresco.reporting.processor.AuditingExportProcessor.java

/** This method should return only if ALL entries up until now() are processed. 
 *  This can mean multiple cycles are needed (limit to 50.000 or any other reasonable amount)
 *  **!! NOT how it works right now!!**/*from  w ww  . j a v  a2s  .  co  m*/
 */
public void processAuditingExport(String auditFeed, String tableName) {
    if (logger.isDebugEnabled())
        logger.debug("enter processAuditingExport " + auditFeed);

    // http://code.google.com/a/apache-extras.org/p/alfresco-opencmis-extension/source/browse/trunk/src/main/java/org/alfresco/cmis/client/authentication/OAuthCMISAuthenticationProvider.java?r=19
    if ((auditFeed != null) && (!"".equals(auditFeed.trim()))) {

        // getLastTimestamp returns actual timestamp, or timestamp in 1970
        String timestamp = dbhb.getLastTimestamp(tableName);

        if ((timestamp != null) && !"".equals(timestamp)) {
            timestamp = timestamp.replaceAll("T", " ").trim();
        }

        SimpleDateFormat format = Constants.getAuditDateFormat();

        Date startDate = new Date();
        try {
            startDate = format.parse(timestamp);
        } catch (java.text.ParseException e1) {
            e1.printStackTrace();
        }
        Long fromTime = startDate.getTime() + 1; // +1 otherwise you always get the last one double

        ReportLine rl = new ReportLine(tableName, getSimpleDateFormat(), reportingHelper);
        Properties replacementTypes = reportingHelper.getReplacementDataType();
        boolean letsContinue = true;

        try {
            if (logger.isDebugEnabled())
                logger.debug("processAuditingExport: Prepping table columns");
            // if specified, respect the max number of results from the audit framework.
            // if not, get as much as you can!
            int maxAmount = Math.min(
                    Integer.parseInt(
                            globalProperties.getProperty(Constants.property_audit_maxResults, "50000")),
                    Integer.MAX_VALUE);

            Properties definition = new Properties();
            definition.setProperty("sys_store_protocol",
                    getClassToColumnType().getProperty("sys_store_protocol", "-"));
            definition.setProperty(Constants.COLUMN_TIMESTAMP,
                    reportingHelper.getClassToColumnType().getProperty("datetime", "-"));
            definition.setProperty(Constants.COLUMN_USERNAME,
                    reportingHelper.getClassToColumnType().getProperty("name", "-"));
            //definition.setProperty("success", getClassToColumnType().getProperty("boolean","-"));
            setTableDefinition(tableName, definition);

            EntryIdCallback changeLogCollectingCallback = new EntryIdCallback(true, rl, replacementTypes,
                    tableName, auditFeed) {
                private String validateColumnName(String tablename) {
                    if (logger.isDebugEnabled())
                        logger.debug("enter validateColumnName: " + tablename);
                    String origTablename = tablename;
                    if (getCache().containsKey(tablename)) {
                        //logger.debug("Cache hit! returning: " + getCache().getProperty(tablename));
                        return getCache().getProperty(tablename);
                    }

                    String replaceChars = "/-:;'.,;";
                    int index = 10;
                    try {
                        for (int i = 0; i < replaceChars.length(); i++) {
                            while (tablename.indexOf(replaceChars.charAt(i)) > -1) {
                                index = tablename.indexOf(replaceChars.charAt(i));
                                //logger.debug("Processing char=" + replaceChars.charAt(i) + " at index="+index + " | " + tablename);

                                // the first
                                if (index == 0) {
                                    tablename = tablename.substring(1, tablename.length());
                                } else {
                                    // the last
                                    if (index == tablename.length() - 1) {
                                        tablename = tablename.substring(0, tablename.length() - 2);
                                    } else {
                                        if ((index < (tablename.length() - 1)) && (index > -1)) {
                                            // otherwise in between
                                            tablename = tablename.substring(0, index) + "_"
                                                    + tablename.substring(index + 1, tablename.length());
                                        } else {
                                            //logger.fatal("That's weird: index=" + index + " and length="+ tablename.length()+ " " + tablename);
                                        }
                                    }
                                } // end if/else index==0
                            } // end while

                        }
                        if (Constants.VENDOR_ORACLE.equalsIgnoreCase(vendor)) {
                            if (tablename.length() > 30)
                                tablename = tablename.substring(0, 30);
                        } // end if Oracle
                          // update the cache with our newly calculated replacement string
                        if (!getCache().containsKey(tablename)) {
                            this.addToCache(origTablename, tablename);
                        }
                    } catch (Exception e) {
                        logger.fatal("That's weird: index=" + index + " and length=" + tablename.length() + " "
                                + tablename);
                        e.getMessage();

                    }

                    if (logger.isDebugEnabled())
                        logger.debug("exit validateColumnName: " + tablename.toLowerCase());
                    return tablename.toLowerCase();
                }

                @Override
                public boolean handleAuditEntry(Long entryId, String user, long time,
                        Map<String, Serializable> values) {
                    // get the datemask in order to convert Date to String and back. 
                    // Remind, the 'T' is missing, and a blank instead. Replace this later 
                    // on in execution (see replaceAll(" ","T");!!)
                    SimpleDateFormat format = Constants.getAuditDateFormat();
                    Date theDate = new Date(time);
                    lastFromTime = time;
                    //process the values into the reporting DB;
                    //logger.debug("id="+ entryId+" user="+ user+" time="+ time+" values"+ values);
                    Set<String> theValues = null;
                    if (values != null) {
                        theValues = values.keySet();
                        Properties definition = new Properties();
                        for (String value : theValues) {
                            try {
                                definition.setProperty(validateColumnName(value),
                                        reportingHelper.getClassToColumnType().getProperty("noderef", "-"));
                                setTableDefinition(getTableName(), definition);
                            } catch (Exception e) {
                                logger.fatal(
                                        "handleAuditEntry: UNABLE to process property from Values Map object");
                            }

                        } // end for
                    } // end if values !=null
                    try {
                        getRl().reset();
                        Properties replacementTypes = reportingHelper.getReplacementDataType();
                        Properties classToColumnType = reportingHelper.getClassToColumnType();
                        getRl().setLine(Constants.COLUMN_SYS_NODE_UUID,
                                reportingHelper.getClassToColumnType().getProperty("noderef"),
                                entryId.toString(), replacementTypes);
                        getRl().setLine(Constants.COLUMN_TIMESTAMP, classToColumnType.getProperty("datetime"),
                                format.format(theDate).replaceAll(" ", "T"), replacementTypes);
                        getRl().setLine(Constants.COLUMN_USERNAME, classToColumnType.getProperty("name"), user,
                                replacementTypes);
                        if (values != null) {
                            for (String value : theValues) {
                                logger.debug("Setting value=" + value);
                                getRl().setLine(validateColumnName(value),
                                        classToColumnType.getProperty("noderef"),
                                        String.valueOf(values.get(value)), replacementTypes);
                            } // end for value:theValues from Map
                        } // end if
                    } catch (Exception e) {
                        logger.fatal("Setting values in ResultLine object failed...");
                        e.printStackTrace();
                    }

                    @SuppressWarnings("unused")
                    int numberOfRows = 0;
                    try {
                        if (dbhb.rowExists(getRl())) {
                            numberOfRows = dbhb.updateIntoTable(getRl());
                            //logger.debug(numberOfRows+ " rows updated");
                        } else {
                            numberOfRows = dbhb.insertIntoTable(getRl());
                            //logger.debug(numberOfRows+ " rows inserted");

                        }
                    } catch (SQLException e) {
                        e.printStackTrace();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    actualAmount++;
                    return super.handleAuditEntry(entryId, user, time, values);
                    //return true;
                } // end handleAuditEntry
            }; //end newEntryIdCallback

            // Contiue to loop until te number of results is less than the max number
            // of hits Then we're done...
            while (letsContinue) {
                this.actualAmount = 0;
                //logger.debug("Before auditQuery, fromtime=" + fromTime + " | Timestamp=" + timestamp);
                AuditQueryParameters params = new AuditQueryParameters();
                params.setApplicationName(auditFeed);
                params.setForward(true);
                params.setFromTime(fromTime);

                auditService.auditQuery(changeLogCollectingCallback, params, maxAmount);
                fromTime = this.lastFromTime;
                if (logger.isDebugEnabled())
                    logger.debug("After auditQuery actual=" + actualAmount + " max=" + maxAmount);

                letsContinue = (actualAmount == maxAmount);
            } // end while

        } catch (ParseException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            rl.reset();
        }
    } // end if auditFeed !="" --> Prevent action if auditLog=enabled but no value specified
    if (logger.isDebugEnabled())
        logger.debug("exit processAuditingExport");
}

From source file:org.alfresco.reporting.script.AlfrescoReporting.java

public void processAuditingExport(String auditFeed) {
    logger.debug("enter processAuditingExport " + auditFeed);

    // http://code.google.com/a/apache-extras.org/p/alfresco-opencmis-extension/source/browse/trunk/src/main/java/org/alfresco/cmis/client/authentication/OAuthCMISAuthenticationProvider.java?r=19
    if ((auditFeed != null) && (!"".equals(auditFeed.trim()))) {
        String tableName = auditFeed.toLowerCase();
        tableName = tableName.replaceAll("-", "_").replaceAll(" ", "_");
        //setTable(tableName);

        dbhb.createEmptyTables(tableName);
        String timestamp = getLastTimestamp(tableName);
        timestamp = timestamp.replaceAll("T", " ").trim();

        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        Date startDate = null;//from  w w  w  .jav  a 2 s  . c om
        try {
            //logger.debug("Parsable date?=" + timestamp);
            startDate = format.parse(timestamp);
        } catch (java.text.ParseException e1) {
            e1.printStackTrace();
        }
        Long fromTime = startDate.getTime() + 1; // +1 otherwise you always get the last one double

        ReportLine rl = new ReportLine(tableName);
        Properties replacementTypes = getReplacementDataType();
        Statement stmt = null;

        try {
            //logger.debug("processAuditingExport: Prepping table columns");
            Properties definition = new Properties();
            definition.setProperty("timestamp", getClassToColumnType().getProperty("datetime", "-"));
            definition.setProperty("username", getClassToColumnType().getProperty("name", "-"));
            //definition.setProperty("success", getClassToColumnType().getProperty("boolean","-"));
            setTableDefinition(definition, tableName);
            //logger.debug("processAuditingExport: Done prepping table columns");

            Connection conn = dbhb.getConnection();
            conn.setAutoCommit(true);
            stmt = conn.createStatement();
            int maxAmount = 50000;
            /*
            try{
               maxAmount = Integer.parseInt(globalProperties.getProperty(Constants.property_audit_maxResults, "50000"));
            } catch (NumberFormatException nfe){
               // nothing
            }
            */

            // Replace this JSON stuff with the Real Thing:
            // http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/repository/source/java/org/alfresco/cmis/changelog/CMISChangeLogServiceImpl.java
            /*
            if (!auditService.isAuditEnabled(auditFeeds, ("/" + auditFeeds)))
              {
                  logger.fatal("Auditing for " + auditFeeds + " is disabled!");
              }
            */
            EntryIdCallback changeLogCollectingCallback = new EntryIdCallback(true, stmt, rl, replacementTypes,
                    tableName, auditFeed) {
                private String validateColumnName(String tablename) {
                    logger.debug("enter validateColumnName: " + tablename);
                    String origTablename = tablename;
                    if (getCache().containsKey(tablename)) {
                        //logger.debug("Cache hit! returning: " + getCache().getProperty(tablename));
                        return getCache().getProperty(tablename);
                    }

                    String replaceChars = "/-:;'.,;";
                    int index = 10;
                    try {
                        for (int i = 0; i < replaceChars.length(); i++) {
                            while (tablename.indexOf(replaceChars.charAt(i)) > -1) {
                                index = tablename.indexOf(replaceChars.charAt(i));
                                //logger.debug("Processing char=" + replaceChars.charAt(i) + " at index="+index + " | " + tablename);

                                // the first
                                if (index == 0) {
                                    tablename = tablename.substring(1, tablename.length());
                                } else {
                                    // the last
                                    if (index == tablename.length() - 1) {
                                        tablename = tablename.substring(0, tablename.length() - 2);
                                    } else {
                                        if ((index < (tablename.length() - 1)) && (index > -1)) {
                                            // otherwise in between
                                            tablename = tablename.substring(0, index) + "_"
                                                    + tablename.substring(index + 1, tablename.length());
                                        } else {
                                            //logger.fatal("That's weird: index=" + index + " and length="+ tablename.length()+ " " + tablename);
                                        }
                                    }
                                } // end if/else index==0
                            } // end while

                        }
                        // update the cache with our newly calculated replacement string
                        if (!getCache().containsKey(tablename)) {
                            this.addToCache(origTablename, tablename);
                        }
                    } catch (Exception e) {
                        logger.fatal("That's weird: index=" + index + " and length=" + tablename.length() + " "
                                + tablename);
                        e.getMessage();

                    }

                    logger.debug("exit validateColumnName: " + tablename.toLowerCase());
                    return tablename.toLowerCase();
                }

                @Override
                public boolean handleAuditEntry(Long entryId, String user, long time,
                        Map<String, Serializable> values) {
                    // get the datemask in order to convert Date to String and back. 
                    // Remind, the 'T' is missing, and a blank instead. Replace this later 
                    // on in execution (see replaceAll(" ","T");!!)
                    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    Date theDate = new Date(time);

                    //process the values into the reporting DB;
                    //logger.debug("id="+ entryId+" user="+ user+" time="+ time+" values"+ values);
                    Set<String> theValues = null;
                    if (values != null) {
                        theValues = values.keySet();
                        Properties definition = new Properties();
                        for (String value : theValues) {
                            try {
                                definition.setProperty(validateColumnName(value),
                                        getClassToColumnType().getProperty("noderef", "-"));
                                setTableDefinition(definition, getTableName());
                            } catch (Exception e) {
                                logger.fatal(
                                        "handleAuditEntry: UNABLE to process property from Values Map object");
                            }

                        } // end for
                    } // end if values !=null
                    try {
                        getRl().reset();
                        getRl().setLine("sys_node_uuid", getClassToColumnType().getProperty("noderef"),
                                entryId.toString(), getReplacementTypes());
                        getRl().setLine("timestamp", getClassToColumnType().getProperty("datetime"),
                                format.format(theDate).replaceAll(" ", "T"), getReplacementTypes());
                        getRl().setLine("username", getClassToColumnType().getProperty("name"), user,
                                getReplacementTypes());
                        if (values != null) {
                            for (String value : theValues) {
                                getRl().setLine(validateColumnName(value),
                                        getClassToColumnType().getProperty("noderef"),
                                        (String) values.get(value), getReplacementTypes());
                            } // end for value:theValues from Map
                        } // end if
                    } catch (Exception e) {
                        logger.error("Setting values in ResultLine object failed...");
                        e.printStackTrace();
                    }

                    int numberOfRows = 0;
                    try {
                        if (dbhb.rowExists(getStatement(), getRl())) {
                            numberOfRows = dbhb.updateIntoTable(getStatement(), getRl());
                            //logger.debug(numberOfRows+ " rows updated");
                        } else {
                            numberOfRows = dbhb.insertIntoTable(getStatement(), getRl());
                            //logger.debug(numberOfRows+ " rows inserted");

                        }
                    } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    return super.handleAuditEntry(entryId, user, time, values);
                    //return true;
                }
            };

            //logger.debug("Before auditQuery, fromtime=" + fromTime + " | Timestamp=" + timestamp);
            AuditQueryParameters params = new AuditQueryParameters();
            params.setApplicationName(auditFeed);
            params.setForward(true);
            params.setFromTime(fromTime);

            auditService.auditQuery(changeLogCollectingCallback, params, maxAmount);
            // logger.debug("After auditQuery");

        } catch (ParseException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            rl.reset();
            try {
                if (stmt != null)
                    stmt.close();
            } catch (SQLException se2) {
                logger.fatal("2#############################################");
            } // nothing we can do
        }
    } // end if auditFeed !="" --> Prevent action if auditLog=enabled but no value specified
    logger.debug("exit processAuditingExport");
}