List of usage examples for javax.ejb EJBException EJBException
public EJBException(Exception ex)
From source file:com.egt.ejb.toolkit.ToolKitSessionBean.java
@Override public void generarEntityClass() { try {//w w w . ja v a 2 s .c om VelocityContext context = new VelocityContext(); String query = VelocityEngineer.write(context, "sdk-query-generar-entity-class.vm").toString(); List<SystemTable> systemTables = systemTableFacade.findByQuery(query, EnumTipoQuery.NATIVE, REFRESH); generarEntityClass(systemTables); TLC.getBitacora().info(Bundle.getString("generar.entities.ok"), systemTables.size()); } catch (Exception ex) { // TLC.getBitacora().fatal(ex); throw ex instanceof EJBException ? (EJBException) ex : new EJBException(ex); } }
From source file:edu.harvard.i2b2.fhirserver.ejb.AuthTokenBean.java
public AuthToken find(String authCode) { try {//from w w w .j a va2s. c o m if (authCode == null) throw new IllegalArgumentException("search parameter:auth code is null"); em.getTransaction().begin(); AuthToken tok = em.find(AuthToken.class, authCode); // .createQuery( // "select a from AuthToken a where AuthorizationCode = :ac ") // .setParameter("ac", authCode).getResultList(); em.getTransaction().commit(); logger.info("found token:" + tok); 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 find(String authCode) { try {/* w ww . jav a 2s . co m*/ if (authCode == null) throw new IllegalArgumentException("search parameter:auth code is null"); //em.getTransaction().begin(); AuthToken tok = em.find(AuthToken.class, authCode); // .createQuery( // "select a from AuthToken a where AuthorizationCode = :ac ") // .setParameter("ac", authCode).getResultList(); //em.getTransaction().commit(); logger.info("found token:" + tok); return tok; } catch (Exception e) { logger.error(e.getMessage(), e); //em.getTransaction().rollback(); throw new EJBException(e.getMessage()); } }
From source file:net.maxgigapop.mrs.driver.GenericRESTDriver.java
@Override @Asynchronous/*from ww w. ja v a 2s . c om*/ public Future<String> commitDelta(DriverSystemDelta aDelta) { DriverInstance driverInstance = aDelta.getDriverInstance(); if (driverInstance == null) { throw new EJBException(String.format("commitDelta see null driverInance for %s", aDelta)); } String subsystemBaseUrl = driverInstance.getProperty("subsystemBaseUrl"); if (subsystemBaseUrl == null) { throw new EJBException(String.format("%s has no property key=subsystemBaseUrl", driverInstance)); } // commit through PUT try { URL url = new URL(String.format("%s/delta/%s/%d/commit", subsystemBaseUrl, aDelta.getReferenceVersionItem().getReferenceUUID(), aDelta.getId())); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); String status = this.executeHttpMethod(url, conn, "PUT", null); //$$ if status == FAILED and raise exception } catch (IOException ex) { throw new EJBException( String.format("%s failed to connect to subsystem with exception (%s)", driverInstance, ex)); } // query through GET boolean doPoll = true; int maxNumPolls = 10; // timeout after 5 minutes -> ? make configurable while (doPoll && (maxNumPolls--) > 0) { try { sleep(30000L); // poll every 30 minutes -> ? make configurable // pull model from REST API URL url = new URL(String.format("%s/delta/%s/%d", subsystemBaseUrl, aDelta.getReferenceVersionItem().getReferenceUUID(), aDelta.getId())); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); String status = this.executeHttpMethod(url, conn, "GET", null); if (status.toUpperCase().equals("ACTIVE")) { doPoll = false; // committed successfully } else if (status.toUpperCase().contains("FAILED")) { throw new EJBException( String.format("%s failed to commit %s with status=%s", driverInstance, aDelta, status)); } } catch (InterruptedException ex) { throw new EJBException(String.format("%s poll for commit status is interrupted", driverInstance)); } catch (IOException ex) { throw new EJBException(String.format("%s failed to communicate with subsystem with exception (%s)", driverInstance, ex)); } } return new AsyncResult<>("SUCCESS"); }
From source file:edu.harvard.i2b2.fhirserver.ejb.AccessTokenBean.java
public AccessToken createIfNotExistsDemoAccessToken() { try {/*from ww w.j ava 2 s . com*/ AccessToken tok = null; logger.info("default token exists? .."); em.getTransaction().begin(); tok = em.find(AccessToken.class, Config.openAccessToken); em.getTransaction().commit(); if (tok == null) { tok = new AccessToken(); tok.setTokenString(Config.openAccessToken); tok.setResourceUserId("demo"); tok.setI2b2Token("demouser"); tok.setI2b2Project("i2b2demo"); tok.setClientId("fcclient1"); tok.setScope("user *.read"); tok.setCreatedDate(new Date()); tok.setExpiryDate(DateUtils.addYears(new Date(), 1000)); logger.info("Demo token does not exist; Hence creating .." + tok.toString()); em.getTransaction().begin(); em.persist(tok); em.getTransaction().commit(); logger.info("Persisted " + tok.toString()); } logger.trace("returning:" + tok.toString()); return tok; } catch (Exception ex) { logger.error(ex.getMessage(), ex); em.getTransaction().rollback(); throw new EJBException(ex.getMessage()); } }
From source file:de.juwimm.cms.authorization.model.UserHbmDaoImpl.java
@Override protected void handleAddGroup(GroupHbm group, String principal, String username) throws Exception { try {/*from w ww .ja v a2s .co m*/ UserHbm userPrincipal = load(principal); UserHbm userToAdd = load(username); if (group.getSite().equals(userPrincipal.getActiveSite())) { userToAdd.getGroups().add(group); group.getUsers().add(userToAdd); } else { throw new EJBException( principal + " has tried to add a Group to a user that does not belong to the activeSite"); } } catch (Exception e) { throw new UserException(e.getMessage()); } }
From source file:edu.harvard.iq.dvn.core.analysis.NetworkDataServiceBean.java
public void initAnalysis(String fileSystemLocation, String sessionId) { try {/*ww w .j a va2 s . co m*/ File fileLocation = new File(fileSystemLocation); String neoDirName = FileUtil.replaceExtension(fileLocation.getName(), NEO4J_EXTENSION); File neoDir = new File(fileLocation.getParent(), neoDirName); // Coy neoDB directory to a temporary location, so this bean can have exclusive access to it. File tempNeoDir = new File(baseTempPath, sessionId + new Long(new Date().getTime()).toString()); tempNeoDir.mkdir(); tempNeoDir.deleteOnExit(); FileUtils.copyDirectory(neoDir, tempNeoDir); // File copyNeoDB = FileUtils. File sqliteFile = new File(fileLocation.getParent(), FileUtil.replaceExtension(fileLocation.getName(), SQLITE_EXTENSION)); try { if (dvnGraphFactory == null) { dvnGraphFactory = new DVNGraphFactory(LIB_PATH); } //dvnGraph = new DVNGraphFactory(LIB_PATH). dvnGraph = dvnGraphFactory.newInstance(tempNeoDir.getAbsolutePath(), sqliteFile.getAbsolutePath(), NEO4J_CONFIG_FILE); //dvnGraph = new DVNGraphImpl(tempNeoDir.getAbsolutePath(), sqliteFile.getAbsolutePath(), NEO4J_CONFIG_FILE); } catch (ClassNotFoundException e) { throw new EJBException(e); } //dvnGraph.initialize(); this.fileSystemLocation = fileSystemLocation; } catch (IOException e) { throw new EJBException(e); } }
From source file:com.geodetix.geo.dao.PostGisGeometryDAOImpl.java
/** * PostGIS implementation of the /* w ww . ja v a2 s . co m*/ * {@link com.geodetix.geo.interfaces.GeometryLocalHome#findByPrimaryKey(java.lang.Integer)} * method * * * @return the found bean's prymary key. * @param primaryKey primary key of searching bean. * @throws javax.ejb.FinderException launched if an error occours during the search operation. */ public java.lang.Integer findByPrimaryKey(java.lang.Integer primaryKey) throws javax.ejb.FinderException { PreparedStatement pstm = null; Connection con = null; ResultSet result = null; try { con = this.dataSource.getConnection(); pstm = con.prepareStatement(PostGisGeometryDAO.FIND_BY_PRIMARY_KEY_STATEMENT); pstm.setInt(1, primaryKey.intValue()); result = pstm.executeQuery(); if (!result.next()) { throw new ObjectNotFoundException("Cannot find Geometry Bean with id = " + primaryKey); } } 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) { } } return primaryKey; }
From source file:edu.harvard.i2b2.oauth2.AccessTokenService.java
public void createIfNotExistsConfigTokens() { try {/*from w w w .j a v a 2 s . c o m*/ AccessToken tok = null; List<String> tokStrList = new ArrayList<String>(); if (serverConfig.GetString(ConfigParameter.openAccessToken) != null) tokStrList.add(serverConfig.GetString(ConfigParameter.openAccessToken)); if (serverConfig.GetString(ConfigParameter.nonExpiringTokenList) != null) tokStrList.addAll( Arrays.asList(serverConfig.GetString(ConfigParameter.nonExpiringTokenList).split("\\|"))); for (String tokString : tokStrList) { logger.info("default tokens exists? ..:" + tokString); tok = em.find(AccessToken.class, tokString); if (tok == null) { tok = new AccessToken(); tok.setTokenString(tokString); tok.setResourceUserId(serverConfig.GetString(ConfigParameter.openI2b2User)); tok.setI2b2Token(serverConfig.GetString(ConfigParameter.openI2b2Password)); tok.setClientId(serverConfig.GetString(ConfigParameter.openClientId)); tok.setScope("user *.read"); tok.setI2b2Url(serverConfig.GetString(ConfigParameter.i2b2Url)); tok.setI2b2Project(serverConfig.GetString(ConfigParameter.openI2b2Project)); tok.setI2b2Domain(serverConfig.GetString(ConfigParameter.i2b2Domain)); tok.setCreatedDate(new Date()); tok.setExpiryDate(DateUtils.addYears(new Date(), 1000)); logger.info("Demo token does not exist; Hence creating .." + tok.toString()); em.persist(tok); logger.info("Persisted " + tok.toString()); } } logger.trace("returning:" + tok.toString()); } catch (Exception ex) { logger.error(ex.getMessage(), ex); throw new EJBException(ex.getMessage()); } }
From source file:com.stratelia.webactiv.webSites.control.WebSiteSessionController.java
/** * initEJB//from w w w.j a va2 s . c o m */ private void initEJB() { // 1 - Remove all data store by this SessionController (includes EJB) webSiteEjb = null; removeSessionTopic(); removeSessionSite(); // 2 - Init EJB used by this SessionController try { setWebSiteEJB(); } catch (Exception e) { throw new EJBException(e); } }