List of usage examples for javax.ejb EJBException EJBException
public EJBException(Exception ex)
From source file:Employee.java
public void doAction() { try {//w w w . j a v a 2 s.co m try { tx.begin(); // do the work... System.out.println("Processing..."); } finally { tx.commit(); } } catch (Exception e) { // handle all the tx.begin()/commit() exceptions throw new EJBException(e); } }
From source file:edu.harvard.i2b2.oauth2.AccessTokenService.java
public void deleteAllAccessTokens() { try {/*w ww.j av a 2 s.c o m*/ em.createQuery("delete from accesstoken where id!='-';").executeUpdate(); } catch (Exception ex) { logger.error(ex.getMessage(), ex); throw new EJBException(ex.getMessage()); } }
From source file:com.geodetix.geo.dao.PostGisGeometryDAOImpl.java
/** Initializes the bean. */ public void init() { try {/* w w w. j a va 2 s. c o m*/ jndiCntx = new InitialContext(); dataSource = (DataSource) jndiCntx.lookup(PostGisGeometryDAO.DATASOURCE_NAME); } catch (NamingException ne) { throw new EJBException(ne); } }
From source file:edu.harvard.i2b2.fhirserver.ejb.AccessTokenBean.java
public void deleteAllAccessTokens() { try {// w w w . j ava 2 s.co m em.getTransaction().begin(); em.createQuery("delete from accesstoken where id!='-';").executeUpdate(); em.getTransaction().commit(); } catch (Exception ex) { logger.error(ex.getMessage(), ex); em.getTransaction().rollback(); throw new EJBException(ex.getMessage()); } }
From source file:net.maxgigapop.mrs.driver.GenericRESTDriver.java
@Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void propagateDelta(DriverInstance driverInstance, DriverSystemDelta aDelta) { driverInstance = DriverInstancePersistenceManager.findById(driverInstance.getId()); aDelta = (DriverSystemDelta) DeltaPersistenceManager.findById(aDelta.getId()); // refresh String subsystemBaseUrl = driverInstance.getProperty("subsystemBaseUrl"); if (subsystemBaseUrl == null) { throw new EJBException(String.format("%s has no property key=subsystemBaseUrl", driverInstance)); }/*from w w w . j a v a 2 s . co m*/ VersionItem refVI = aDelta.getReferenceVersionItem(); if (refVI == null) { throw new EJBException(String.format("%s has no referenceVersionItem", aDelta)); } try { // compose string body (delta) using JSONObject JSONObject deltaJSON = new JSONObject(); deltaJSON.put("id", Long.toString(aDelta.getId())); deltaJSON.put("referenceVersion", refVI.getReferenceUUID()); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); deltaJSON.put("creationTime", dateFormat.format(new Date()).toString()); if (aDelta.getModelAddition() != null && aDelta.getModelAddition().getOntModel() != null) { String ttlModelAddition = ModelUtil.marshalOntModel(aDelta.getModelAddition().getOntModel()); deltaJSON.put("modelAddition", ttlModelAddition); } if (aDelta.getModelReduction() != null && aDelta.getModelReduction().getOntModel() != null) { String ttlModelReduction = ModelUtil.marshalOntModel(aDelta.getModelReduction().getOntModel()); deltaJSON.put("modelReduction", ttlModelReduction); } // push via REST POST URL url = new URL(String.format("%s/delta", subsystemBaseUrl)); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); String status = this.executeHttpMethod(url, conn, "POST", deltaJSON.toString()); if (!status.toUpperCase().equals("CONFIRMED")) { throw new EJBException( String.format("%s failed to push %s into CONFIRMED status", driverInstance, aDelta)); } } catch (Exception e) { throw new EJBException(String.format("propagateDelta failed for %s with %s due to exception (%s)", driverInstance, aDelta, e.getMessage())); } }
From source file:be.fedict.eid.idp.sp.saml2.AuthenticationResponseServiceBean.java
@Override public void validateServiceCertificate(SamlAuthenticationPolicy authenticationPolicy, List<X509Certificate> certificateChain) throws SecurityException { LOG.debug("validate saml response policy=" + authenticationPolicy.getUri() + " cert.chain.size=" + certificateChain.size());/* w w w . ja v a 2 s . c om*/ String idpIdentity = ConfigServlet.getIdpIdentity(); if (null != idpIdentity && !idpIdentity.trim().isEmpty()) { LOG.debug("validate IdP Identity with " + idpIdentity); String fingerprint; try { fingerprint = DigestUtils.shaHex(certificateChain.get(0).getEncoded()); } catch (CertificateEncodingException e) { throw new SecurityException(e); } if (!fingerprint.equals(idpIdentity)) { throw new EJBException( "IdP Identity " + "thumbprint mismatch: got: " + fingerprint + " expected: " + idpIdentity); } } }
From source file:de.juwimm.cms.authorization.model.UserHbmImpl.java
/** * @see de.juwimm.cms.authorization.model.UserHbm#dropGroup(de.juwimm.cms.authorization.model.GroupHbm) *///from w w w. ja v a 2 s. c om @Override public void dropGroup(de.juwimm.cms.authorization.model.GroupHbm group) { try { getGroups().remove(group); group.getUsers().remove(this); } catch (Exception ex) { throw new EJBException(ex.getMessage()); } }
From source file:nl.knaw.dans.dataverse.DeletedStudyServiceBean.java
public DeletedStudy getDeletedStudyByHarvestInfo(VDC dataverse, String harvestIdentifier) { String queryStr = "SELECT s FROM DeletedStudy s WHERE s.owner.id = '" + dataverse.getId() + "' and s.harvestIdentifier = '" + harvestIdentifier + "'"; Query query = em.createQuery(queryStr); List resultList = query.getResultList(); DeletedStudy deletedStudy = null;/* www . j a v a 2 s .c o m*/ if (resultList.size() > 1) { throw new EJBException("More than one study found with owner_id= " + dataverse.getId() + " and harvestIdentifier= " + harvestIdentifier); } if (resultList.size() == 1) { deletedStudy = (DeletedStudy) resultList.get(0); } return deletedStudy; }
From source file:edu.harvard.i2b2.fhirserver.ejb.AuthTokenBean.java
public AuthToken createAuthToken(String authCode, String resourceUserId, String i2b2Token, String clientRedirectUri, String clientId, String state, String scope, String i2b2Project) { try {//from w ww . j a v a2 s .c om AuthToken tok = new AuthToken(); tok.setAuthorizationCode(authCode); tok.setResourceUserId(resourceUserId); tok.setI2b2Token(i2b2Token); tok.setClientRedirectUri(clientRedirectUri); tok.setClientId(clientId); tok.setState(state); tok.setScope(scope); tok.setI2b2Project(i2b2Project); tok.setCreatedDate(new Date()); tok.setExpiryDate(DateUtils.addMinutes(new Date(), 30)); logger.info("Created authToken.." + tok.toString()); em.getTransaction().begin(); em.persist(tok); em.getTransaction().commit(); logger.info("Persisted authToken" + 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.oauth2.AccessTokenService.java
public AccessToken createAccessToken(String authCode, String resourceUserId, String i2b2Token, String i2b2Project, String clientId, String scope) { try {//from w w w. j av a2 s . c om AccessToken tok = new AccessToken(); tok.setTokenString(authCode); 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.persist(tok); logger.info("Persisted " + tok.toString()); return tok; } catch (Exception ex) { logger.error(ex.getMessage(), ex); throw new EJBException(ex.getMessage()); } }