Search in sources :

Example 1 with BuildRevisionParameters

use of org.cerberus.crud.entity.BuildRevisionParameters in project cerberus-source by cerberustesting.

the class BuildRevisionParametersDAO method readByVarious1ByCriteria.

@Override
public AnswerList readByVarious1ByCriteria(String system, String application, String build, String revision, int start, int amount, String column, String dir, String searchTerm, Map<String, List<String>> individualSearch) {
    AnswerList response = new AnswerList();
    MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
    msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
    List<BuildRevisionParameters> brpList = new ArrayList<BuildRevisionParameters>();
    StringBuilder searchSQL = new StringBuilder();
    List<String> individalColumnSearchValues = new ArrayList<String>();
    StringBuilder query = new StringBuilder();
    // SQL_CALC_FOUND_ROWS allows to retrieve the total number of columns by disrearding the limit clauses that
    // were applied -- used for pagination p
    query.append("SELECT SQL_CALC_FOUND_ROWS * FROM buildrevisionparameters ");
    searchSQL.append(" where 1=1 ");
    if (!StringUtil.isNullOrEmpty(searchTerm)) {
        searchSQL.append(" and (`id` like ?");
        searchSQL.append(" or `Build` like ?");
        searchSQL.append(" or `Revision` like ?");
        searchSQL.append(" or `Release` like ?");
        searchSQL.append(" or `Application` like ?");
        searchSQL.append(" or `Project` like ?");
        searchSQL.append(" or `TicketIDFixed` like ?");
        searchSQL.append(" or `BugIDFixed` like ?");
        searchSQL.append(" or `Link` like ?");
        searchSQL.append(" or `ReleaseOwner` like ?");
        searchSQL.append(" or `datecre` like ?");
        searchSQL.append(" or `jenkinsbuildid` like ?");
        searchSQL.append(" or `mavengroupid` like ?");
        searchSQL.append(" or `mavenartifactid` like ?");
        searchSQL.append(" or `repositoryurl` like ?");
        searchSQL.append(" or `mavenversion` like ? )");
    }
    if (individualSearch != null && !individualSearch.isEmpty()) {
        searchSQL.append(" and ( 1=1 ");
        for (Map.Entry<String, List<String>> entry : individualSearch.entrySet()) {
            searchSQL.append(" and ");
            searchSQL.append(SqlUtil.getInSQLClauseForPreparedStatement(entry.getKey(), entry.getValue()));
            individalColumnSearchValues.addAll(entry.getValue());
        }
        searchSQL.append(" )");
    }
    if (!StringUtil.isNullOrEmpty(system)) {
        searchSQL.append(" and application in (SELECT application FROM application WHERE `System` = ? )");
    }
    if (!StringUtil.isNullOrEmpty(application)) {
        searchSQL.append(" and (`Application`= ? )");
    }
    if (!StringUtil.isNullOrEmpty(build)) {
        searchSQL.append(" and (`Build`= ? )");
    }
    if (!StringUtil.isNullOrEmpty(revision)) {
        searchSQL.append(" and (`Revision`= ? )");
    }
    query.append(searchSQL);
    if (!StringUtil.isNullOrEmpty(column)) {
        query.append(" order by `").append(column).append("` ").append(dir);
    }
    if ((amount <= 0) || (amount >= MAX_ROW_SELECTED)) {
        query.append(" limit ").append(start).append(" , ").append(MAX_ROW_SELECTED);
    } else {
        query.append(" limit ").append(start).append(" , ").append(amount);
    }
    // Debug message on SQL.
    if (LOG.isDebugEnabled()) {
        LOG.debug("SQL : " + query.toString());
    }
    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query.toString());
        try {
            int i = 1;
            if (!StringUtil.isNullOrEmpty(searchTerm)) {
                preStat.setString(i++, "%" + searchTerm + "%");
                preStat.setString(i++, "%" + searchTerm + "%");
                preStat.setString(i++, "%" + searchTerm + "%");
                preStat.setString(i++, "%" + searchTerm + "%");
                preStat.setString(i++, "%" + searchTerm + "%");
                preStat.setString(i++, "%" + searchTerm + "%");
                preStat.setString(i++, "%" + searchTerm + "%");
                preStat.setString(i++, "%" + searchTerm + "%");
                preStat.setString(i++, "%" + searchTerm + "%");
                preStat.setString(i++, "%" + searchTerm + "%");
                preStat.setString(i++, "%" + searchTerm + "%");
                preStat.setString(i++, "%" + searchTerm + "%");
                preStat.setString(i++, "%" + searchTerm + "%");
                preStat.setString(i++, "%" + searchTerm + "%");
                preStat.setString(i++, "%" + searchTerm + "%");
                preStat.setString(i++, "%" + searchTerm + "%");
            }
            for (String individualColumnSearchValue : individalColumnSearchValues) {
                preStat.setString(i++, individualColumnSearchValue);
            }
            if (!StringUtil.isNullOrEmpty(system)) {
                preStat.setString(i++, system);
            }
            if (!StringUtil.isNullOrEmpty(application)) {
                preStat.setString(i++, application);
            }
            if (!StringUtil.isNullOrEmpty(build)) {
                preStat.setString(i++, build);
            }
            if (!StringUtil.isNullOrEmpty(revision)) {
                preStat.setString(i++, revision);
            }
            ResultSet resultSet = preStat.executeQuery();
            try {
                // gets the data
                while (resultSet.next()) {
                    brpList.add(this.loadFromResultSet(resultSet));
                }
                // get the total number of rows
                resultSet = preStat.executeQuery("SELECT FOUND_ROWS()");
                int nrTotalRows = 0;
                if (resultSet != null && resultSet.next()) {
                    nrTotalRows = resultSet.getInt(1);
                }
                if (brpList.size() >= MAX_ROW_SELECTED) {
                    // Result of SQl was limited by MAX_ROW_SELECTED constrain. That means that we may miss some lines in the resultList.
                    LOG.error("Partial Result in the query.");
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_WARNING_PARTIAL_RESULT);
                    msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Maximum row reached : " + MAX_ROW_SELECTED));
                    response = new AnswerList(brpList, nrTotalRows);
                } else if (brpList.size() <= 0) {
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
                    response = new AnswerList(brpList, nrTotalRows);
                } else {
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
                    msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT"));
                    response = new AnswerList(brpList, nrTotalRows);
                }
            } 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 {
                if (resultSet != null) {
                    resultSet.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 {
            if (preStat != null) {
                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 (!this.databaseSpring.isOnTransaction()) {
                if (connection != null) {
                    connection.close();
                }
            }
        } catch (SQLException exception) {
            LOG.warn("Unable to close connection : " + exception.toString());
        }
    }
    response.setResultMessage(msg);
    response.setDataList(brpList);
    return response;
}
Also used : AnswerList(org.cerberus.util.answer.AnswerList) MessageEvent(org.cerberus.engine.entity.MessageEvent) ArrayList(java.util.ArrayList) BuildRevisionParameters(org.cerberus.crud.entity.BuildRevisionParameters) FactoryBuildRevisionParameters(org.cerberus.crud.factory.impl.FactoryBuildRevisionParameters) IFactoryBuildRevisionParameters(org.cerberus.crud.factory.IFactoryBuildRevisionParameters) AnswerList(org.cerberus.util.answer.AnswerList) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

Example 2 with BuildRevisionParameters

use of org.cerberus.crud.entity.BuildRevisionParameters in project cerberus-source by cerberustesting.

the class BuildRevisionParametersDAO method readByVarious2.

@Override
public AnswerItem readByVarious2(String build, String revision, String release, String application) {
    AnswerItem ans = new AnswerItem();
    MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
    msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
    BuildRevisionParameters result = null;
    StringBuilder query = new StringBuilder();
    query.append("Select * FROM  buildrevisionparameters ");
    query.append(" WHERE build= ? and revision= ? and `release` = ?  and application = ? ");
    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query.toString());
        try {
            preStat.setString(1, build);
            preStat.setString(2, revision);
            preStat.setString(3, release);
            preStat.setString(4, application);
            ResultSet resultSet = preStat.executeQuery();
            try {
                // gets the data
                if (resultSet.first()) {
                    result = loadFromResultSet(resultSet);
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
                    msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT"));
                    ans.setItem(result);
                } else {
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
                }
            } 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 {
                resultSet.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 {
            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());
        }
    }
    // sets the message
    ans.setResultMessage(msg);
    return ans;
}
Also used : BuildRevisionParameters(org.cerberus.crud.entity.BuildRevisionParameters) FactoryBuildRevisionParameters(org.cerberus.crud.factory.impl.FactoryBuildRevisionParameters) IFactoryBuildRevisionParameters(org.cerberus.crud.factory.IFactoryBuildRevisionParameters) MessageEvent(org.cerberus.engine.entity.MessageEvent) AnswerItem(org.cerberus.util.answer.AnswerItem)

Example 3 with BuildRevisionParameters

use of org.cerberus.crud.entity.BuildRevisionParameters in project cerberus-source by cerberustesting.

the class BuildRevisionParametersDAO method readLastBySystem.

@Override
public AnswerItem readLastBySystem(String system) {
    AnswerItem ans = new AnswerItem();
    BuildRevisionParameters result = null;
    StringBuilder query = new StringBuilder();
    query.append("SELECT * from buildrevisionparameters brp ");
    query.append("	left outer join buildrevisioninvariant bri1 on brp.build = bri1.versionname and bri1.level=1 and bri1.`System` = ? ");
    query.append("	left outer join buildrevisioninvariant bri2 on brp.revision = bri2.versionname and bri2.level=2 and bri2.`System` = ? ");
    query.append("WHERE 1=1 ");
    query.append("	and application in (SELECT application FROM application WHERE `System` = ? ) ");
    query.append("ORDER BY bri1.seq desc, bri2.seq desc, brp.datecre desc limit 1; ");
    MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
    msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
    // Debug message on SQL.
    if (LOG.isDebugEnabled()) {
        LOG.debug("SQL : " + query.toString());
    }
    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query.toString());
        try {
            int i = 1;
            preStat.setString(i++, system);
            preStat.setString(i++, system);
            preStat.setString(i++, system);
            ResultSet resultSet = preStat.executeQuery();
            try {
                if (resultSet.first()) {
                    result = loadFromResultSet(resultSet);
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
                    msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT LAST"));
                    ans.setItem(result);
                } else {
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
                }
            } 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 {
                resultSet.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 {
            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());
        }
    }
    // sets the message
    ans.setResultMessage(msg);
    return ans;
}
Also used : BuildRevisionParameters(org.cerberus.crud.entity.BuildRevisionParameters) FactoryBuildRevisionParameters(org.cerberus.crud.factory.impl.FactoryBuildRevisionParameters) IFactoryBuildRevisionParameters(org.cerberus.crud.factory.IFactoryBuildRevisionParameters) MessageEvent(org.cerberus.engine.entity.MessageEvent) AnswerItem(org.cerberus.util.answer.AnswerItem)

Example 4 with BuildRevisionParameters

use of org.cerberus.crud.entity.BuildRevisionParameters in project cerberus-source by cerberustesting.

the class BuildRevisionParametersDAO method readByKeyTech.

@Override
public AnswerItem readByKeyTech(int id) {
    AnswerItem ans = new AnswerItem();
    BuildRevisionParameters result = null;
    final String query = "SELECT * FROM `buildrevisionparameters` WHERE `id` = ?";
    MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
    msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
    // Debug message on SQL.
    if (LOG.isDebugEnabled()) {
        LOG.debug("SQL : " + query);
    }
    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query);
        try {
            preStat.setInt(1, id);
            ResultSet resultSet = preStat.executeQuery();
            try {
                if (resultSet.first()) {
                    result = loadFromResultSet(resultSet);
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
                    msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT"));
                    ans.setItem(result);
                } else {
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
                }
            } 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 {
                resultSet.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 {
            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());
        }
    }
    // sets the message
    ans.setResultMessage(msg);
    return ans;
}
Also used : BuildRevisionParameters(org.cerberus.crud.entity.BuildRevisionParameters) FactoryBuildRevisionParameters(org.cerberus.crud.factory.impl.FactoryBuildRevisionParameters) IFactoryBuildRevisionParameters(org.cerberus.crud.factory.IFactoryBuildRevisionParameters) MessageEvent(org.cerberus.engine.entity.MessageEvent) AnswerItem(org.cerberus.util.answer.AnswerItem)

Example 5 with BuildRevisionParameters

use of org.cerberus.crud.entity.BuildRevisionParameters in project cerberus-source by cerberustesting.

the class BuildRevisionParametersDAO method readMaxSVNReleasePerApplication.

@Override
public AnswerList readMaxSVNReleasePerApplication(String system, String build, String revision, String lastBuild, String lastRevision) {
    AnswerList response = new AnswerList();
    MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
    msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
    List<BuildRevisionParameters> brpList = new ArrayList<BuildRevisionParameters>();
    StringBuilder searchSQL = new StringBuilder();
    StringBuilder query = new StringBuilder();
    // SQL_CALC_FOUND_ROWS allows to retrieve the total number of columns by disrearding the limit clauses that
    // were applied -- used for pagination p
    query.append("SELECT * from ( ");
    query.append("SELECT Application, max(`rel1`) rel FROM (");
    query.append("SELECT brp.Application, CAST(`Release` AS UNSIGNED) rel1 ");
    query.append(" FROM buildrevisionparameters brp ");
    query.append("JOIN application a on a.application = brp.application ");
    query.append("JOIN buildrevisioninvariant bri on bri.versionname = brp.revision and bri.`system` = ? and bri.`level` = 2 ");
    query.append(" WHERE 1=1 ");
    query.append(" and a.`system` = ? ");
    query.append(" and brp.build = ? ");
    if (lastBuild.equalsIgnoreCase(build)) {
        // If last version is on the same build.
        if (StringUtil.isNullOrEmpty(lastRevision)) {
            // Same build and revision some we filter only the current content.
            // revision
            query.append(" and bri.seq = (select seq from buildrevisioninvariant where `system` = ? and `level` = 2 and `versionname` = ? ) ");
        } else {
            // 2 different revisions inside the same build, we take the content between the 2.
            // lastRevision
            query.append(" and bri.seq > (select seq from buildrevisioninvariant where `system` = ? and `level` = 2 and `versionname` = ? ) ");
        }
    }
    // revision
    query.append(" and bri.seq <= (select seq from buildrevisioninvariant where `system` = ? and `level` = 2 and `versionname` = ? )");
    // Release needs to be an svn number
    query.append(" and `release` REGEXP '^-?[0-9]+$' ");
    // We need to have a jenkinsBuildID
    query.append(" and jenkinsbuildid is not null and jenkinsbuildid != '' ");
    query.append("   ORDER BY brp.Application ) as al1 ");
    query.append("   GROUP BY Application  ORDER BY Application) as al ");
    query.append("JOIN buildrevisionparameters brp ");
    query.append("  ON brp.application=al.application and brp.release=al.rel and brp.build = ? ");
    query.append(" JOIN application app ");
    query.append(" ON app.application=al.application ");
    query.append("WHERE app.`system` = ? ;");
    // Debug message on SQL.
    if (LOG.isDebugEnabled()) {
        LOG.debug("SQL : " + query.toString());
        LOG.debug("SQL.param.system : " + system);
        LOG.debug("SQL.param.build : " + build);
        LOG.debug("SQL.param.revision : " + revision);
        LOG.debug("SQL.param.lastBuild : " + lastBuild);
        LOG.debug("SQL.param.lastRevision : " + lastRevision);
    }
    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query.toString());
        try {
            int i = 1;
            preStat.setString(i++, system);
            preStat.setString(i++, system);
            preStat.setString(i++, build);
            if (lastBuild.equalsIgnoreCase(build)) {
                if (StringUtil.isNullOrEmpty(lastRevision)) {
                    // if lastRevision is not defined, we filter only the current content.
                    preStat.setString(i++, system);
                    preStat.setString(i++, revision);
                } else {
                    // 2 different revisions inside the same build, we take the content between the 2.
                    preStat.setString(i++, system);
                    preStat.setString(i++, lastRevision);
                }
            }
            preStat.setString(i++, system);
            preStat.setString(i++, revision);
            preStat.setString(i++, build);
            preStat.setString(i++, system);
            ResultSet resultSet = preStat.executeQuery();
            try {
                // gets the data
                while (resultSet.next()) {
                    BuildRevisionParameters brpItem = this.loadFromResultSet(resultSet);
                    brpItem.setAppDeployType(resultSet.getString("app.deploytype"));
                    brpList.add(brpItem);
                }
                // get the total number of rows
                resultSet = preStat.executeQuery("SELECT FOUND_ROWS()");
                int nrTotalRows = 0;
                if (resultSet != null && resultSet.next()) {
                    nrTotalRows = resultSet.getInt(1);
                }
                if (brpList.size() >= MAX_ROW_SELECTED) {
                    // Result of SQl was limited by MAX_ROW_SELECTED constrain. That means that we may miss some lines in the resultList.
                    LOG.error("Partial Result in the query.");
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_WARNING_PARTIAL_RESULT);
                    msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Maximum row reached : " + MAX_ROW_SELECTED));
                    response = new AnswerList(brpList, nrTotalRows);
                } else if (brpList.size() <= 0) {
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
                    response = new AnswerList(brpList, nrTotalRows);
                } else {
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
                    msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "SELECT"));
                    response = new AnswerList(brpList, nrTotalRows);
                }
            } 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 {
                if (resultSet != null) {
                    resultSet.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 {
            if (preStat != null) {
                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 (!this.databaseSpring.isOnTransaction()) {
                if (connection != null) {
                    connection.close();
                }
            }
        } catch (SQLException exception) {
            LOG.warn("Unable to close connection : " + exception.toString());
        }
    }
    response.setResultMessage(msg);
    response.setDataList(brpList);
    return response;
}
Also used : AnswerList(org.cerberus.util.answer.AnswerList) BuildRevisionParameters(org.cerberus.crud.entity.BuildRevisionParameters) FactoryBuildRevisionParameters(org.cerberus.crud.factory.impl.FactoryBuildRevisionParameters) IFactoryBuildRevisionParameters(org.cerberus.crud.factory.IFactoryBuildRevisionParameters) MessageEvent(org.cerberus.engine.entity.MessageEvent) ArrayList(java.util.ArrayList)

Aggregations

BuildRevisionParameters (org.cerberus.crud.entity.BuildRevisionParameters)16 AnswerItem (org.cerberus.util.answer.AnswerItem)11 MessageEvent (org.cerberus.engine.entity.MessageEvent)10 IFactoryBuildRevisionParameters (org.cerberus.crud.factory.IFactoryBuildRevisionParameters)9 IBuildRevisionParametersService (org.cerberus.crud.service.IBuildRevisionParametersService)9 JSONObject (org.json.JSONObject)8 ArrayList (java.util.ArrayList)6 FactoryBuildRevisionParameters (org.cerberus.crud.factory.impl.FactoryBuildRevisionParameters)6 AnswerList (org.cerberus.util.answer.AnswerList)6 List (java.util.List)4 ILogEventService (org.cerberus.crud.service.ILogEventService)4 ApplicationContext (org.springframework.context.ApplicationContext)4 IOException (java.io.IOException)3 ServletException (javax.servlet.ServletException)3 CerberusException (org.cerberus.exception.CerberusException)3 Answer (org.cerberus.util.answer.Answer)3 JSONArray (org.json.JSONArray)3 PolicyFactory (org.owasp.html.PolicyFactory)3 IApplicationService (org.cerberus.crud.service.IApplicationService)2 BuildRevisionParametersService (org.cerberus.crud.service.impl.BuildRevisionParametersService)2