Package com.philip.journal.core.exception

Examples of com.philip.journal.core.exception.JournalException


            final Properties properties = new Properties();
            try {
                properties.load(getClass().getResourceAsStream("/build.num"));
                version.append("-b" + (Integer.parseInt(properties.getProperty("build.number")) - 1));
            } catch (final IOException e) {
                throw new JournalException(e.getMessage(), e);
            }
        }
        logger.info("version: " + version);
        filterConfig.getServletContext().setAttribute(Constant.APP_VERSION, version);
    }
View Full Code Here


        final HibernateTemplate hibernateTemplate = getHibernateTemplate();
        try {
            hibernateTemplate.deleteAll(listObj);
            hibernateTemplate.flush();
        } catch (final HibernateOptimisticLockingFailureException holfe) {
            throw new JournalException(Messages.Error.JE_OBJ_MISS_ERR, holfe);
        } catch (final DataIntegrityViolationException exception) {
            throw new JournalException(exception.getMessage(), exception.getCause().getCause());//NOPMD Wrap internal exception with client exception.
        }

    }
View Full Code Here

            Order order;
            try {
                objParam[0] = tokens[0];
                order = (Order) Order.class.getMethod(tokens[1], strClsArr).invoke(null, objParam);
            } catch (final Exception e) {
                throw new JournalException(e.getMessage(), e);
            }
            criteria.addOrder(order);
        }

        final List<E> retval = new ArrayList<E>();
View Full Code Here

        long pkeyId;
        final String fieldName = (String) BeanUtils.getProperty(object, "primaryKeyField");
        pkeyId = (Long) BeanUtils.getProperty(object, fieldName);

        if (hibernateTemplate.get(getTargetClass(), pkeyId) == null) {
            throw new JournalException("Error deleting non-existent entity.");
        }

        hibernateTemplate.delete(object);
        hibernateTemplate.flush();
    }
View Full Code Here

        } catch (final HibernateSystemException hse) {
            LOGGER.error(hse.getMessage());
        } catch (final DataAccessException dae) {
            final Throwable cause = dae.getCause();
            if (cause.getClass().equals(org.hibernate.StaleStateException.class)) {
                throw new JournalException(Messages.Error.IAE_GENERIC, Messages.Error.IAE_INV_UPDATE,
                        cause.getMessage(), dae);
            } else if (cause.getClass().equals(PropertyValueException.class)) {
                throw new JournalException(cause.getMessage(), cause); // NOPMD by r39
            } else if (cause.getClass().equals(TransientObjectException.class)) {
                throw new JournalException(Messages.Error.JE_UNSVD_ROBJ_ERR, cause); // NOPMD by
            } else {
                final String errorMsg = ((SQLException) dae.getCause().getCause()).getMessage();
                throw new JournalException(errorMsg, dae);
            }
        } catch (final Exception e) {
            throw new JournalException(e.getMessage(), e);
        }
    }
View Full Code Here

    @Override
    public long addBranch(final Map<String, Object> session, final long parentId, final String branchName)
    {
        final Branch parentBranch = getDaoFacade().getBranchDAO().read(parentId);
        if (parentBranch == null) {
            throw new JournalException(Messages.Error.JE_INV_BRANCHID);
        } else if (StringUtils.getInstance().isNullOrEmpty(branchName)) {
            throw new JournalException(Messages.Error.JE_INV_BRANCHNAME);
        }

        final Branch branch = new Branch(branchName, parentBranch);
        branch.setCreator((User) session.get(Constant.CURRENT_USER));
        getDaoFacade().getBranchDAO().save(branch);
View Full Code Here

    @Override
    public void deleteBranch(final Map<String, Object> session, final long branchId)
    {
        if (branchId == Constant.ROOT_ID) {
            throw new JournalException(Messages.Error.JE_INV_BRANCHID);
        }
        final Branch branch = getDaoFacade().getBranchDAO().read(branchId);
        if (branch == null) {
            throw new JournalException(Messages.Error.JE_INV_BRANCHID);
        }

        final List<Branch> withSubBranches = new ArrayList<Branch>();
        withSubBranches.add(branch);
        final List<Branch> children = getChildren(branch);
View Full Code Here

    @Override
    public void renameBranch(final Map<String, Object> session, final long branchId, final String newName)
    {
        final Branch branch = getDaoFacade().getBranchDAO().read(branchId);
        if (branch == null) {
            throw new JournalException(Messages.Error.JE_INV_BRANCHID);
        }

        branch.setName(newName);
        getDaoFacade().getBranchDAO().save(branch);
    }
View Full Code Here

        final BranchDAO branchDao = getDaoFacade().getBranchDAO();
        final Branch branch = branchDao.read(branchId);
        final Branch parent = branchDao.read(newParentId);

        if (branch == null || parent == null) {
            throw new JournalException(Messages.Error.JE_INV_BRANCHID);
        }
        final String newIds = Constant.BRANCHID_PREFIX + newParentId;
        final String branchIds = Constant.BRANCHID_PREFIX + branchId;
        final String branchPath = getBranchPath(session, parent);
        final int newIdx = branchPath.indexOf(newIds);
        final int parentIdx = branchPath.indexOf(branchIds);

        if (parentIdx > -1 && newIdx > parentIdx) {
            throw new JournalException(Messages.Error.JE_INV_BRANCHID);
        }

        branch.setParent(parent);
        branchDao.save(branch);
    }
View Full Code Here

                final Branch parent = param.getParent();
                if (parent != null) {//not Root.
                    final List<Branch> siblings = mockBranchDAO.readAllByParent(parent.getBranchId());
                    for (final Branch branch : siblings) {
                        if (branch.getBranchId() != param.getBranchId() && branch.getName().equals(param.getName())) {
                            throw new JournalException(JournalTestCommon.TEST_JRNL_ERRORMSG);
                        }
                    }
                }
                return null;
            }
View Full Code Here

TOP

Related Classes of com.philip.journal.core.exception.JournalException

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.