Search in sources :

Example 11 with Answer

use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.

the class CountryEnvParam_logDAO method delete.

@Override
public Answer delete(CountryEnvParam_log countryEnvParamLog) {
    MessageEvent msg = null;
    final String query = "DELETE FROM countryenvparam_log WHERE id = ? ";
    // Debug message on SQL.
    if (LOG.isDebugEnabled()) {
        LOG.debug("SQL : " + query);
    }
    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query);
        try {
            preStat.setLong(1, countryEnvParamLog.getId());
            preStat.executeUpdate();
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
            msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "DELETE"));
        } catch (SQLException exception) {
            LOG.error("Unable to execute query : " + exception.toString());
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
            msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
        } finally {
            preStat.close();
        }
    } catch (SQLException exception) {
        LOG.error("Unable to execute query : " + exception.toString());
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
        msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException exception) {
            LOG.error("Unable to close connection : " + exception.toString());
        }
    }
    return new Answer(msg);
}
Also used : Answer(org.cerberus.util.answer.Answer) SQLException(java.sql.SQLException) MessageEvent(org.cerberus.engine.entity.MessageEvent) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement)

Example 12 with Answer

use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.

the class CountryEnvParam_logDAO method update.

@Override
public Answer update(CountryEnvParam_log countryEnvPramaLog) {
    MessageEvent msg = null;
    final String query = "UPDATE countryenvparam_log SET system = ?, Country = ?, Environment = ?, Build = ?, Revision = ?, " + "Chain = ?, Description = ?, Creator = ?  WHERE id = ? ";
    // Debug message on SQL.
    if (LOG.isDebugEnabled()) {
        LOG.debug("SQL : " + query);
    }
    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query);
        try {
            preStat.setString(1, countryEnvPramaLog.getSystem());
            preStat.setString(2, countryEnvPramaLog.getCountry());
            preStat.setString(3, countryEnvPramaLog.getEnvironment());
            preStat.setString(4, countryEnvPramaLog.getBuild());
            preStat.setString(5, countryEnvPramaLog.getRevision());
            preStat.setInt(6, countryEnvPramaLog.getChain());
            preStat.setString(7, countryEnvPramaLog.getDescription());
            preStat.setString(8, countryEnvPramaLog.getCreator());
            preStat.setLong(9, countryEnvPramaLog.getId());
            preStat.executeUpdate();
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
            msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "UPDATE"));
        } catch (SQLException exception) {
            LOG.error("Unable to execute query : " + exception.toString());
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
            msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
        } finally {
            preStat.close();
        }
    } catch (SQLException exception) {
        LOG.error("Unable to execute query : " + exception.toString());
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
        msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException exception) {
            LOG.error("Unable to close connection : " + exception.toString());
        }
    }
    return new Answer(msg);
}
Also used : Answer(org.cerberus.util.answer.Answer) SQLException(java.sql.SQLException) MessageEvent(org.cerberus.engine.entity.MessageEvent) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement)

Example 13 with Answer

use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.

the class CountryEnvironmentDatabaseDAO method delete.

@Override
public Answer delete(CountryEnvironmentDatabase object) {
    MessageEvent msg = null;
    final String query = "DELETE FROM `countryenvironmentdatabase` WHERE `system`=? and `country`=? and `environment`=? and `database`=?";
    // Debug message on SQL.
    if (LOG.isDebugEnabled()) {
        LOG.debug("SQL : " + query);
    }
    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query);
        try {
            preStat.setString(1, object.getSystem());
            preStat.setString(2, object.getCountry());
            preStat.setString(3, object.getEnvironment());
            preStat.setString(4, object.getDatabase());
            preStat.executeUpdate();
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
            msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "DELETE"));
        } catch (SQLException exception) {
            LOG.error("Unable to execute query : " + exception.toString());
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
            msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
        } finally {
            preStat.close();
        }
    } catch (SQLException exception) {
        LOG.error("Unable to execute query : " + exception.toString());
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
        msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException exception) {
            LOG.warn("Unable to close connection : " + exception.toString());
        }
    }
    return new Answer(msg);
}
Also used : Answer(org.cerberus.util.answer.Answer) SQLException(java.sql.SQLException) MessageEvent(org.cerberus.engine.entity.MessageEvent) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement)

Example 14 with Answer

use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.

the class CountryEnvironmentParametersDAO method update.

@Override
public Answer update(CountryEnvironmentParameters object) {
    MessageEvent msg = null;
    final String query = "UPDATE `countryenvironmentparameters` SET `IP`=?, `URL`=?, `URLLOGIN`=?, `domain`=?, Var1=?, Var2=?, Var3=?, Var4=?, poolSize=?  where `system`=? and `country`=? and `environment`=? and `application`=? ";
    // Debug message on SQL.
    if (LOG.isDebugEnabled()) {
        LOG.debug("SQL : " + query);
    }
    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query);
        try {
            preStat.setString(1, object.getIp());
            preStat.setString(2, object.getUrl());
            preStat.setString(3, object.getUrlLogin());
            preStat.setString(4, object.getDomain());
            preStat.setString(5, object.getVar1());
            preStat.setString(6, object.getVar2());
            preStat.setString(7, object.getVar3());
            preStat.setString(8, object.getVar4());
            preStat.setInt(9, object.getPoolSize());
            preStat.setString(10, object.getSystem());
            preStat.setString(11, object.getCountry());
            preStat.setString(12, object.getEnvironment());
            preStat.setString(13, object.getApplication());
            preStat.executeUpdate();
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
            msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "UPDATE"));
        } catch (SQLException exception) {
            LOG.error("Unable to execute query : " + exception.toString());
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
            msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
        } finally {
            preStat.close();
        }
    } catch (SQLException exception) {
        LOG.error("Unable to execute query : " + exception.toString());
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
        msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException exception) {
            LOG.warn("Unable to close connection : " + exception.toString());
        }
    }
    return new Answer(msg);
}
Also used : Answer(org.cerberus.util.answer.Answer) SQLException(java.sql.SQLException) MessageEvent(org.cerberus.engine.entity.MessageEvent) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement)

Example 15 with Answer

use of org.cerberus.util.answer.Answer in project cerberus-source by cerberustesting.

the class CountryEnvironmentParametersDAO method delete.

@Override
public Answer delete(CountryEnvironmentParameters object) {
    MessageEvent msg = null;
    final String query = "DELETE FROM `countryenvironmentparameters` WHERE `system`=? and `country`=? and `environment`=? and `application`=? ";
    // Debug message on SQL.
    if (LOG.isDebugEnabled()) {
        LOG.debug("SQL : " + query);
    }
    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query);
        try {
            preStat.setString(1, object.getSystem());
            preStat.setString(2, object.getCountry());
            preStat.setString(3, object.getEnvironment());
            preStat.setString(4, object.getApplication());
            preStat.executeUpdate();
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
            msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "DELETE"));
        } catch (SQLException exception) {
            LOG.error("Unable to execute query : " + exception.toString());
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
            msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
        } finally {
            preStat.close();
        }
    } catch (SQLException exception) {
        LOG.error("Unable to execute query : " + exception.toString());
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
        msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException exception) {
            LOG.warn("Unable to close connection : " + exception.toString());
        }
    }
    return new Answer(msg);
}
Also used : Answer(org.cerberus.util.answer.Answer) SQLException(java.sql.SQLException) MessageEvent(org.cerberus.engine.entity.MessageEvent) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement)

Aggregations

Answer (org.cerberus.util.answer.Answer)241 MessageEvent (org.cerberus.engine.entity.MessageEvent)227 Connection (java.sql.Connection)127 PreparedStatement (java.sql.PreparedStatement)127 SQLException (java.sql.SQLException)127 ApplicationContext (org.springframework.context.ApplicationContext)77 JSONObject (org.json.JSONObject)75 ILogEventService (org.cerberus.crud.service.ILogEventService)74 PolicyFactory (org.owasp.html.PolicyFactory)60 AnswerItem (org.cerberus.util.answer.AnswerItem)53 CerberusException (org.cerberus.exception.CerberusException)45 ArrayList (java.util.ArrayList)35 JSONException (org.json.JSONException)26 IOException (java.io.IOException)23 ServletException (javax.servlet.ServletException)19 JSONArray (org.json.JSONArray)15 LogEventService (org.cerberus.crud.service.impl.LogEventService)13 TestCase (org.cerberus.crud.entity.TestCase)10 ITestCaseService (org.cerberus.crud.service.ITestCaseService)10 CountryEnvParam (org.cerberus.crud.entity.CountryEnvParam)8