Example usage for javax.ejb EJBException EJBException

List of usage examples for javax.ejb EJBException EJBException

Introduction

In this page you can find the example usage for javax.ejb EJBException EJBException.

Prototype

public EJBException(Exception ex) 

Source Link

Document

Constructs an EJBException that embeds the originally thrown exception.

Usage

From source file:de.juwimm.cms.authorization.model.UserHbmDaoImpl.java

@Override
protected UserLoginValue handleGetUserLoginValue(UserHbm user) throws Exception {
    UserLoginValue value = new UserLoginValue();
    try {/*from w  ww. j  a  v  a2s .  co m*/
        value.setUser(user.getUserValue());
        value.setSiteConfigXML(user.getConfigXML());
        if (user.getActiveSite() != null) {
            value.setSiteName(user.getActiveSite().getName());
            Collection<UnitHbm> units = getUnits4ActiveSite(user);
            if (units != null) {
                UnitValue[] uv = new UnitValue[units.size()];
                int i = 0;
                for (UnitHbm unit : units) {
                    uv[i++] = getUnitHbmDao().getDao(unit);
                }
                value.setUnits(uv);
            }
        }
    } catch (Exception e) {
        throw new EJBException(e);
    }
    return value;
}

From source file:edu.harvard.i2b2.fhirserver.ejb.AuthTokenBean.java

public AuthToken findByClientId(String clientId) {
    try {/* ww  w .j  ava2 s.  co m*/
        AuthToken tok = null;
        em.getTransaction().begin();
        List<AuthToken> list = em.createQuery("select a from AuthToken a where clientId = :ac ")
                .setParameter("ac", clientId).getResultList();
        em.getTransaction().commit();
        if (list.size() > 0)
            tok = list.get(0);
        return tok;
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        em.getTransaction().rollback();
        throw new EJBException(e.getMessage());
    }

}

From source file:edu.harvard.i2b2.oauth2.AuthTokenService.java

public AuthToken findByClientId(String clientId) {
    try {//w  ww.  jav  a  2 s  .  co  m
        AuthToken tok = null;
        //em.getTransaction().begin();
        List<AuthToken> list = em.createQuery("select a from AuthToken a where clientId = :ac ")
                .setParameter("ac", clientId).getResultList();
        //em.getTransaction().commit();
        if (list.size() > 0)
            tok = list.get(0);
        return tok;
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        //em.getTransaction().rollback();
        throw new EJBException(e.getMessage());
    }

}

From source file:com.stratelia.webactiv.newsEdito.control.NewsEditoSessionController.java

/**
 * Constructor declaration/*  w  w  w.j  a va  2s . c o  m*/
 *
 * @see
 */
public NewsEditoSessionController(MainSessionController mainSessionCtrl, ComponentContext context) {
    super(mainSessionCtrl, context, "org.silverpeas.newsEdito.multilang.newsEditoBundle");
    SilverTrace.info("NewsEdito", "NewsEditoSessionControl.constructor", "NewsEdito.MSG_ENTRY_METHOD");

    try {
        nodeBm = EJBUtilitaire.getEJBObjectRef(JNDINames.NODEBM_EJBHOME, NodeBm.class);
        publicationBm = EJBUtilitaire.getEJBObjectRef(JNDINames.PUBLICATIONBM_EJBHOME, PublicationBm.class);
        favoritBm = EJBUtilitaire.getEJBObjectRef(JNDINames.FAVORITBM_EJBHOME, FavoritBm.class);
        statisticBm = EJBUtilitaire.getEJBObjectRef(JNDINames.STATISTICBM_EJBHOME, StatisticBm.class);

    } catch (Exception e) {
        throw new EJBException("NewsEditoSessionControl() : Exception : " + e);
    }
}

From source file:edu.harvard.i2b2.fhirserver.ejb.AccessTokenBean.java

public AccessToken createAccessTokenAndDeleteAuthToken(String authCode, String accessCode,
        String resourceUserId, String i2b2Token, String i2b2Project, String clientId, String scope) {
    try {/*  w  ww. j a  va  2 s.  c o  m*/
        AccessToken tok = new AccessToken();
        tok.setTokenString(accessCode);
        tok.setResourceUserId(resourceUserId);
        tok.setI2b2Token(i2b2Token);
        tok.setI2b2Project(i2b2Project);
        tok.setClientId(clientId);
        tok.setScope(scope);
        tok.setCreatedDate(new Date());
        tok.setExpiryDate(DateUtils.addMinutes(new Date(), 30));

        logger.info("Created .." + tok.toString());
        em.getTransaction().begin();
        em.persist(tok);

        AuthToken authTok = em.find(AuthToken.class, authCode);
        if (authTok == null)
            throw new RuntimeException("auth Tok was not found");
        logger.info("Removing authTok ");
        em.remove(authTok);

        em.getTransaction().commit();

        logger.info("Persisted " + tok.toString());
        return tok;
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
        em.getTransaction().rollback();
        throw new EJBException(ex.getMessage());
    }
}

From source file:edu.harvard.i2b2.fhirserver.ejb.AuthTokenBean.java

public void shutdownDb() {
    try {// w w  w.j  a v  a2 s . c  o m
        em.createQuery("SHUTDOWN").executeUpdate();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        em.getTransaction().rollback();
        throw new EJBException(e.getMessage());
    }

}

From source file:nl.knaw.dans.dataverse.DeletedStudyServiceBean.java

public DeletedStudy getDeletedStudyByGlobalId(String identifier) {
    String protocol = null;/*from www .  ja  v a 2  s .c  o m*/
    String authority = null;
    String deletedStudyId = null;
    int index1 = identifier.indexOf(':');
    int index2 = identifier.indexOf('/');
    int index3 = 0;
    if (index1 == -1) {
        throw new EJBException("Error parsing identifier: " + identifier + ". ':' not found in string");
    } else {
        protocol = identifier.substring(0, index1);
    }
    if (index2 == -1) {
        throw new EJBException("Error parsing identifier: " + identifier + ". '/' not found in string");

    } else {
        authority = identifier.substring(index1 + 1, index2);
    }
    if (protocol.equals("doi")) {
        index3 = identifier.indexOf('/', index2 + 1);
        if (index3 == -1) {
            deletedStudyId = identifier.substring(index2 + 1).toUpperCase();
        } else {
            authority = identifier.substring(index1 + 1, index3);
            deletedStudyId = identifier.substring(index3 + 1).toUpperCase();
        }
    } else {
        deletedStudyId = identifier.substring(index2 + 1).toUpperCase();
    }

    String queryStr = "SELECT s from DeletedStudy s where s.deletedStudyId = :deletedStudyId  and s.protocol= :protocol and s.authority= :authority";

    DeletedStudy deletedStudy = null;
    try {
        Query query = em.createQuery(queryStr);
        query.setParameter("deletedStudyId", deletedStudyId);
        query.setParameter("protocol", protocol);
        query.setParameter("authority", authority);
        deletedStudy = (DeletedStudy) query.getSingleResult();
    } catch (javax.persistence.NoResultException e) {
        // DO nothing, just return null.
    }
    return deletedStudy;
}

From source file:edu.harvard.i2b2.oauth2.AuthTokenService.java

public void shutdownDb() {
    try {//w  ww . j  a  v a2 s .c  om
        em.createQuery("SHUTDOWN").executeUpdate();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        //em.getTransaction().rollback();
        throw new EJBException(e.getMessage());
    }

}

From source file:edu.harvard.i2b2.fhirserver.ejb.AccessTokenBean.java

public List<AccessToken> getAuthTokens() {
    try {/*w  w  w .  j  a  va 2s  . c o m*/
        em.getTransaction().begin();
        List<AccessToken> tokens = em.createQuery("from AccessToken").getResultList();
        em.getTransaction().commit();
        return tokens;
    } catch (Exception e) {
        em.getTransaction().rollback();
        logger.error(e.getMessage(), e);
        throw new EJBException(e.getMessage());
    }
}

From source file:com.geodetix.geo.dao.PostGisGeometryDAOImpl.java

/**
 * PostGIS implementation of the  /*from  w ww  .ja va2  s.  co m*/
 * {@link com.geodetix.geo.interfaces.GeometryLocalHome#findByPolygon(org.postgis.Polygon)}
 * method
 * 
 * @return a collection of bean's primary key beeing found.
 * @param polygon the {@link org.postgis.Polygon} to search in.
 * @throws javax.ejb.FinderException launched if an error occours during the search operation.
 */
public java.util.Collection findByPolygon(org.postgis.Polygon polygon) throws javax.ejb.FinderException {

    PreparedStatement pstm = null;
    Connection con = null;
    ResultSet result = null;

    try {

        con = this.dataSource.getConnection();

        pstm = con.prepareStatement(PostGisGeometryDAO.FIND_BY_POLYGON_STATEMENT);

        pstm.setObject(1, new PGgeometry(polygon));

        result = pstm.executeQuery();

        Vector keys = new Vector();

        while (result.next()) {
            keys.addElement(result.getObject("id"));
        }

        return keys;

    } catch (SQLException se) {
        throw new EJBException(se);

    } finally {
        try {
            if (result != null) {
                result.close();
            }
        } catch (Exception e) {
        }

        try {
            if (pstm != null) {
                pstm.close();
            }
        } catch (Exception e) {
        }

        try {
            if (con != null) {
                con.close();
            }
        } catch (Exception e) {
        }
    }
}