Package org.openengsb.core.edb.api

Examples of org.openengsb.core.edb.api.EDBException


            TypedQuery<JPACommit> typedQuery = entityManager.createQuery(query).setMaxResults(1);
            try {
                return typedQuery.getSingleResult();
            } catch (NoResultException ex) {
                throw new EDBException("there was no Object found with the given query parameters", ex);
            }
        }
    }
View Full Code Here


            TypedQuery<JPAObject> typedQuery = entityManager.createQuery(query).setMaxResults(1);
            List<JPAObject> resultList = typedQuery.getResultList();

            if (resultList.size() < 1) {
                throw new EDBException("Failed to query existing object");
            } else if (resultList.size() > 1) {
                throw new EDBException("Received more than 1 object which should not be possible!");
            }

            return resultList.get(0);
        }
    }
View Full Code Here

            query.select(from).where(criteriaBuilder.equal(from.get("revision"), revision));
            TypedQuery<JPACommit> typedQuery = entityManager.createQuery(query);
            List<JPACommit> result = typedQuery.getResultList();
            switch (result.size()) {
                case 0:
                    throw new EDBException("There is no commit with the given revision " + revision);
                case 1:
                    return result.get(0);
                default:
                    throw new EDBException("More than one commit with the given revision found!");
            }
        }
    }
View Full Code Here

    /**
     * Performs the actual commit logic for the EDB, including the hooks and the revision checking.
     */
    protected Long performCommitLogic(EDBCommit commit) throws EDBException {
        if (!(commit instanceof JPACommit)) {
            throw new EDBException("The given commit type is not supported.");
        }
        if (commit.isCommitted()) {
            throw new EDBException("EDBCommit is already commitet.");
        }
        if (revisionCheckEnabled && commit.getParentRevisionNumber() != null
                && !commit.getParentRevisionNumber().equals(getCurrentRevisionNumber())) {
            throw new EDBException("EDBCommit do not have the correct head revision number.");
        }
        runBeginCommitHooks(commit);
        EDBException exception = runPreCommitHooks(commit);
        if (exception != null) {
            return runErrorHooks(commit, exception);
        }
        Long timestamp = performCommit((JPACommit) commit);
        runEDBPostHooks(commit);
View Full Code Here

                commitTransaction();
            } catch (Exception ex) {
                try {
                    rollbackTransaction();
                } catch (Exception e) {
                    throw new EDBException("Failed to rollback transaction to EDB", e);
                }
                throw new EDBException("Failed to commit transaction to EDB", ex);
            }
            return timestamp;
        }
    }
View Full Code Here

     * Runs all registered pre commit hooks on the EDBCommit object. Logs exceptions which occurs in the hooks, except
     * for ServiceUnavailableExceptions and EDBExceptions. If an EDBException occurs, the function returns this
     * exception.
     */
    private EDBException runPreCommitHooks(EDBCommit commit) {
        EDBException exception = null;
        for (EDBPreCommitHook hook : preCommitHooks) {
            try {
                hook.onPreCommit(commit);
            } catch (ServiceUnavailableException e) {
                // Ignore
View Full Code Here

                logger.info("Deleted commit " + commit.getRevisionNumber());
            } catch (Exception ex) {
                try {
                    rollbackTransaction();
                } catch (Exception e) {
                    throw new EDBException("Failed to rollback transaction to EDB", e);
                }
                throw new EDBException("Failed to commit transaction to EDB", ex);
            }
        }
    }
View Full Code Here

        getLogger().debug("loading the log of JPAObject with the oid {} from "
                + "the timestamp {} to the timestamp {}", new Object[]{ oid, from, to });
        List<EDBObject> history = getHistoryForTimeRange(oid, from, to);
        List<JPACommit> commits = dao.getJPACommit(oid, from, to);
        if (history.size() != commits.size()) {
            throw new EDBException("inconsistent log " + Integer.toString(commits.size()) + " commits for "
                    + Integer.toString(history.size()) + " history entries");
        }
        List<EDBLogEntry> log = new ArrayList<EDBLogEntry>();
        for (int i = 0; i < history.size(); ++i) {
            log.add(new LogEntry(commits.get(i), history.get(i)));
View Full Code Here

        getLogger().debug("load the elements of the JPAHead with the timestamp {}", timestamp);
        JPAHead head = dao.getJPAHead(timestamp);
        if (head != null) {
            return head.getEDBObjects();
        }
        throw new EDBException("Failed to get head for timestamp " + Long.toString(timestamp));
    }
View Full Code Here

    public List<EDBObject> query(QueryRequest request) throws EDBException {
        getLogger().debug("Query for objects based on the request: {}", request);
        try {
            return EDBUtils.convertJPAObjectsToEDBObjects(dao.query(request));
        } catch (Exception ex) {
            throw new EDBException("Failed to query for objects with the given map", ex);
        }
    }
View Full Code Here

TOP

Related Classes of org.openengsb.core.edb.api.EDBException

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.