Package org.b3log.latke.repository

Examples of org.b3log.latke.repository.RepositoryException


        try {
            return Role.ADMIN_ROLE.equals(user.getString(User.USER_ROLE));
        } catch (final JSONException e) {
            LOGGER.log(Level.SEVERE, e.getMessage(), e);

            throw new RepositoryException(e);
        }
    }
View Full Code Here


    @Override
    public String add(final JSONObject jsonObject) throws RepositoryException {
        final JdbcTransaction currentTransaction = TX.get();
        if (null == currentTransaction) {
            throw new RepositoryException("Invoking add() outside a transaction");
        }

        final Connection connection = getConnection();
        final List<Object> paramList = new ArrayList<Object>();
        final StringBuilder sql = new StringBuilder();
        String id = null;

        try {
            id = buildAddSql(jsonObject, paramList, sql);
            JdbcUtil.executeSql(sql.toString(), paramList, connection);
        } catch (final SQLException se) {
            LOGGER.log(Level.SEVERE, "add:"
                                     + se.getMessage(), se);
            throw new JDBCRepositoryException(se);
        } catch (final Exception e) {
            LOGGER.log(Level.SEVERE, "add:"
                                     + e.getMessage(), e);
            throw new RepositoryException(e);
        }

        return id;
    }
View Full Code Here

        }

        final JdbcTransaction currentTransaction = TX.get();

        if (null == currentTransaction) {
            throw new RepositoryException("Invoking update() outside a transaction");
        }

        final JSONObject oldJsonObject = get(id);

        final Connection connection = getConnection();
        final List<Object> paramList = new ArrayList<Object>();
        final StringBuilder sqlBuilder = new StringBuilder();
        try {
            update(id, oldJsonObject, jsonObject, paramList, sqlBuilder);

            final String sql = sqlBuilder.toString();
            if (Strings.isEmptyOrNull(sql)) {
                return;
            }

            JdbcUtil.executeSql(sql, paramList, connection);
        } catch (final SQLException se) {
            LOGGER.log(Level.SEVERE, "update:"
                                     + se.getMessage(), se);
            throw new JDBCRepositoryException(se);
        } catch (final Exception e) {
            LOGGER.log(Level.SEVERE, "update:"
                                     + e.getMessage(), e);
            throw new RepositoryException(e);
        }
    }
View Full Code Here

        }

        final JdbcTransaction currentTransaction = TX.get();

        if (null == currentTransaction) {
            throw new RepositoryException("Invoking remove() outside a transaction");
        }

        final StringBuilder sql = new StringBuilder();
        final Connection connection = getConnection();

        try {
            remove(id, sql);
            JdbcUtil.executeSql(sql.toString(), connection);
        } catch (final SQLException se) {
            LOGGER.log(Level.SEVERE, "update:"
                                     + se.getMessage(), se);
            throw new JDBCRepositoryException(se);
        } catch (final Exception e) {
            LOGGER.log(Level.SEVERE, "remove:"
                                     + e.getMessage(), e);
            throw new RepositoryException(e);
        }
    }
View Full Code Here

        } catch (final SQLException e) {
            throw new JDBCRepositoryException(e);
        } catch (final Exception e) {
            LOGGER.log(Level.SEVERE, "get:"
                                     + e.getMessage(), e);
            throw new RepositoryException(e);
        } finally {
            closeQueryConnection(connection);
        }

        return ret;
View Full Code Here

        } catch (final SQLException e) {
            throw new JDBCRepositoryException(e);
        } catch (final Exception e) {
            LOGGER.log(Level.SEVERE, "query: "
                                     + e.getMessage(), e);
            throw new RepositoryException(e);
        } finally {
            closeQueryConnection(connection);
        }

        return ret;
View Full Code Here

        } catch (final SQLException se) {
            LOGGER.log(Level.SEVERE, "update:" + se.getMessage(), se);
            throw new JDBCRepositoryException(se);
        } catch (final Exception e) {
            LOGGER.log(Level.SEVERE, "getRandomly:" + e.getMessage(), e);
            throw new RepositoryException(e);
        } finally {
            closeQueryConnection(connection);
        }

        return jsonObjects;
View Full Code Here

                                     + se.getMessage(), se);
            throw new JDBCRepositoryException(se);
        } catch (final Exception e) {
            LOGGER.log(Level.SEVERE, "count :"
                                     + e.getMessage(), e);
            throw new RepositoryException(e);
        } finally {
            closeQueryConnection(connection);
        }

        return count;
View Full Code Here

        if (jdbcTransaction == null || !jdbcTransaction.isActive()) {
            try {
                connection.close();
            } catch (final SQLException e) {
                LOGGER.log(Level.SEVERE, "Can not close database connection", e);
                throw new RepositoryException(e);
            }
        } else {
            LOGGER.log(Level.FINEST, "Do not close query connection caused by in a transaction");
        }
    }
View Full Code Here

                break;
            case IN:
                filterOperator = "in";
                break;
            default:
                throw new RepositoryException("Unsupported filter operator[" + propertyFilter.getOperator() + "]");
        }

        if (FilterOperator.IN != propertyFilter.getOperator()) {
            filterSql.append(propertyFilter.getKey()).append(filterOperator).append("?");
            paramList.add(propertyFilter.getValue());
View Full Code Here

TOP

Related Classes of org.b3log.latke.repository.RepositoryException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.