List of usage examples for javax.ejb EJBException getCause
public synchronized Throwable getCause()
From source file:ch.puzzle.itc.mobiliar.presentation.resourcesedit.CreateResourceController.java
private String handleEJBException(String newResourceName, EJBException e) { String errorMessage;/*from www . jav a2 s . c o m*/ if (e.getCause() instanceof NotAuthorizedException || e.getCause() instanceof NotAuthorizedException) { errorMessage = e.getCause().getMessage(); } else if (e.getCause() instanceof PersistenceException) { errorMessage = "A resource with group name \"" + newResourceName + "\" already exist and can not be created!"; } else { throw e; } return errorMessage; }
From source file:ch.puzzle.itc.mobiliar.presentation.applist.ApplistView.java
/** * Entfernen einer Applikationsgruppe.// w w w . j a v a2 s . c o m */ private boolean removeAppServer(Integer selectedAppServerId) { boolean isSuccessful = false; try { if (selectedAppServerId == null) { String errorMessage = "No application server selected."; GlobalMessageAppender.addErrorMessage(errorMessage); } else { try { resourceBoundary.deleteApplicationServerById(selectedAppServerId); String message = "Applicationserver successfully deleted"; GlobalMessageAppender.addSuccessMessage(message); isSuccessful = true; } catch (EJBException e) { if (e.getCause() instanceof NotAuthorizedException) { GlobalMessageAppender.addErrorMessage(e.getCause().getMessage()); } else { throw e; } } } } catch (ResourceNotFoundException e) { String errorMessage = "Could not load selected server for deletion."; GlobalMessageAppender.addErrorMessage(errorMessage); } catch (Exception e) { String errorMessage = "Could not delete selected application server."; GlobalMessageAppender.addErrorMessage(errorMessage); } return isSuccessful; }
From source file:ch.puzzle.itc.mobiliar.presentation.applist.ApplistView.java
/** * Applikation entfernen/*ww w . jav a2s.c o m*/ */ private boolean removeApp(Integer applicationId) { boolean isSuccessful = false; try { if (applicationId == null) { String errorMessage = "No application selected."; GlobalMessageAppender.addErrorMessage(errorMessage); } else { try { resourceBoundary.removeResource(ForeignableOwner.getSystemOwner(), applicationId); String message = "Application successfully deleted"; GlobalMessageAppender.addSuccessMessage(message); isSuccessful = true; } catch (EJBException e) { if (e.getCause() instanceof NotAuthorizedException) { GlobalMessageAppender.addErrorMessage(e.getCause().getMessage()); } else { throw e; } } } } catch (ResourceNotFoundException e) { String errorMessage = "Could not load selected application for deletation."; GlobalMessageAppender.addErrorMessage(errorMessage); } catch (ForeignableOwnerViolationException e) { GlobalMessageAppender.addErrorMessage("Application with id " + applicationId + " can not be deleted by owner " + e.getViolatingOwner()); } catch (Exception e) { String errorMessage = "Could not delete selected application."; GlobalMessageAppender.addErrorMessage(errorMessage); } return isSuccessful; }
From source file:edu.harvard.iq.dvn.core.index.IndexServiceBean.java
public void deleteIndexList(List<Long> studyIds) { Indexer indexer = Indexer.getInstance(); /*//from w ww .j a v a 2 s. c o m try { indexer.setup(); } catch (IOException ex) { ex.printStackTrace(); } */ for (Iterator it = studyIds.iterator(); it.hasNext();) { Long elem = (Long) it.next(); try { deleteDocument(elem.longValue()); } catch (EJBException e) { if (e.getCause() instanceof IllegalArgumentException) { System.out.println("Study id " + elem.longValue() + " not found"); e.printStackTrace(); } else { throw e; } } } }
From source file:edu.harvard.iq.dvn.core.index.IndexServiceBean.java
public void updateIndexList(List<Long> studyIds) { long ioProblemCount = 0; boolean ioProblem = false; Indexer indexer = Indexer.getInstance(); boolean deleteSuccess = true; /*/* ww w .j a v a 2 s. c om*/ try { indexer.setup(); } catch (IOException ex) { ex.printStackTrace(); } */ for (Iterator it = studyIds.iterator(); it.hasNext();) { Long elem = (Long) it.next(); try { deleteSuccess = true; try { indexer.deleteDocumentCarefully(elem.longValue()); } catch (IOException ioe) { deleteSuccess = false; } if (deleteSuccess) { try { addDocument(elem.longValue()); } catch (IOException ex) { ioProblem = true; ioProblemCount++; Logger.getLogger(IndexServiceBean.class.getName()).log(Level.SEVERE, null, ex); } } } catch (EJBException e) { if (e.getCause() instanceof IllegalArgumentException) { System.out.println("Study id " + elem.longValue() + " not found"); e.printStackTrace(); } else { throw e; } } } handleIOProblems(ioProblem, ioProblemCount); }
From source file:gov.nih.nci.caarray.test.api.external.v1_0.java.SearchServiceTest.java
@Test public void testGetAnnotationSet_Null() throws Exception { logForSilverCompatibility(TEST_NAME, "testGetAnnotationSet_Null"); try {// w w w .j a v a 2 s .c o m logForSilverCompatibility(TEST_OUTPUT, "null request"); AnnotationSet aset = service.getAnnotationSet(null); logForSilverCompatibility(TEST_OUTPUT, "unexpected outcome"); fail(); } catch (javax.ejb.EJBException e) { assertEquals(NullPointerException.class, e.getCausedByException().getClass()); logForSilverCompatibility(TEST_OUTPUT, "null request validation :" + e.getCause()); } }
From source file:edu.harvard.iq.dvn.core.web.admin.OptionsPage.java
private Map determineStudyIds(String studyIds) { Map tokenizedLists = determineIds(studyIds); List invalidStudyIdList = new ArrayList(); for (Iterator<Long> iter = ((List<Long>) tokenizedLists.get("idList")).iterator(); iter.hasNext();) { Long id = iter.next();/*from w w w . jav a 2 s. c o m*/ try { studyService.getStudy(id); } catch (EJBException e) { if (e.getCause() instanceof IllegalArgumentException) { invalidStudyIdList.add(id); iter.remove(); } else { throw e; } } } tokenizedLists.put("invalidStudyIdList", invalidStudyIdList); return tokenizedLists; }
From source file:org.ejbca.core.protocol.cmp.CrmfRATcpRequestTest.java
private void createCmpUser(String username, String userDN) throws AuthorizationDeniedException, UserDoesntFullfillEndEntityProfile, ApprovalException, WaitingForApprovalException, EjbcaException, FinderException { // Make user that we know... boolean userExists = false; try {/* ww w . j ava 2 s.c o m*/ userAdminSession.addUser(admin, username, "foo123", userDN, null, "cmptest@primekey.se", false, SecConst.EMPTY_ENDENTITYPROFILE, SecConst.CERTPROFILE_FIXED_ENDUSER, SecConst.USER_ENDUSER, SecConst.TOKEN_SOFT_PEM, 0, caid); log.debug("created user: " + username + ", foo123, " + userDN); } catch (EJBException e) { if (e.getCause() instanceof PersistenceException) { userExists = true; } } if (userExists) { log.debug("User " + username + " already exists."); userAdminSession.setUserStatus(admin, username, UserDataConstants.STATUS_NEW); log.debug("Reset status to NEW"); } }
From source file:org.ejbca.ui.web.admin.configuration.EjbcaWebBean.java
public GlobalConfiguration initialize(HttpServletRequest request, String... resources) throws Exception { if (!initialized) { requestServerName = getRequestServerName(request); final X509Certificate[] certificates = (X509Certificate[]) request .getAttribute("javax.servlet.request.X509Certificate"); if (certificates == null || certificates.length == 0) { throw new AuthenticationFailedException("Client certificate required."); } else {// www. jav a 2s. c o m final Set<X509Certificate> credentials = new HashSet<X509Certificate>(); credentials.add(certificates[0]); final AuthenticationSubject subject = new AuthenticationSubject(null, credentials); administrator = authenticationSession.authenticate(subject); if (administrator == null) { throw new AuthenticationFailedException( "Authentication failed for certificate: " + CertTools.getSubjectDN(certificates[0])); } } commonInit(); adminspreferences = new AdminPreferenceDataHandler((X509CertificateAuthenticationToken) administrator); // Set ServletContext for reading language files from resources servletContext = request.getSession(true).getServletContext(); // Check if certificate and user is an RA Admin final String userdn = CertTools.getSubjectDN(certificates[0]); final DNFieldExtractor dn = new DNFieldExtractor(userdn, DNFieldExtractor.TYPE_SUBJECTDN); usercommonname = dn.getField(DNFieldExtractor.CN, 0); if (log.isDebugEnabled()) { log.debug("Verifying authorization of '" + userdn + "'"); } final String issuerDN = CertTools.getIssuerDN(certificates[0]); final String sernostr = CertTools.getSerialNumberAsString(certificates[0]); final BigInteger serno = CertTools.getSerialNumber(certificates[0]); certificatefingerprint = CertTools.getFingerprintAsString(certificates[0]); if (!endEntityManagementSession.checkIfCertificateBelongToUser(serno, issuerDN)) { throw new RuntimeException("Certificate with SN " + serno + " did not belong to user " + issuerDN); } Map<String, Object> details = new LinkedHashMap<String, Object>(); if (certificateStoreSession.findCertificateByIssuerAndSerno(issuerDN, serno) == null) { details.put("msg", "Logging in : Administrator Certificate is issued by external CA"); } if (WebConfiguration.getAdminLogRemoteAddress()) { details.put("remoteip", request.getRemoteAddr()); } if (WebConfiguration.getAdminLogForwardedFor()) { String addr = request.getHeader("X-Forwarded-For"); if (addr != null) addr = addr.replaceAll("[^a-zA-Z0-9.:-_]", "?"); details.put("forwardedip", addr); } if (details.isEmpty()) { details = null; } auditSession.log(EjbcaEventTypes.ADMINWEB_ADMINISTRATORLOGGEDIN, EventStatus.SUCCESS, EjbcaModuleTypes.ADMINWEB, EjbcaServiceTypes.EJBCA, administrator.toString(), Integer.toString(issuerDN.hashCode()), sernostr, null, details); } try { if (resources.length > 0 && !authorizationSession.isAuthorized(administrator, resources)) { throw new AuthorizationDeniedException("You are not authorized to view this page."); } } catch (EJBException e) { // Will this code ever execute? You are "initialized" (logged in) when the database went under // and your AppServer + JDBC driver throws an EJBException with SQLException as cause..? // Since the errorpage.jsp requires a database connection to show, it does not make any sense // to move this code there.. final Throwable cause = e.getCause(); if (cause instanceof SQLException || cause.getMessage().indexOf("SQLException", 0) >= 0) { throw new Exception(getText("DATABASEDOWN"), e); } throw e; } if (!initialized) { currentadminpreference = null; if (certificatefingerprint != null) { currentadminpreference = adminspreferences.getAdminPreference(certificatefingerprint); } if (currentadminpreference == null) { currentadminpreference = adminspreferences.getDefaultAdminPreference(); } adminsweblanguage = new WebLanguages(servletContext, globalconfiguration, currentadminpreference.getPreferedLanguage(), currentadminpreference.getSecondaryLanguage()); initialized = true; } return globalconfiguration; }
From source file:org.rhq.enterprise.server.discovery.DiscoveryBossBeanTest.java
@Test(groups = "integration.ejb3") public void testManuallyAddResource() throws Exception { InventoryReport inventoryReport = new InventoryReport(agent); Resource platform = new Resource(prefix("alpha"), prefix("platform"), platformType); Resource server = new Resource(prefix("bravo"), prefix("server"), serverType); platform.addChildResource(server);/* ww w .j a v a 2 s . c o m*/ Resource service2 = new Resource(prefix("delta"), prefix("service 2"), serviceType2); server.addChildResource(service2); platform.setUuid(String.valueOf(new Random().nextInt())); server.setUuid(String.valueOf(new Random().nextInt())); service2.setUuid(String.valueOf(new Random().nextInt())); inventoryReport.addAddedRoot(platform); MergeInventoryReportResults results = discoveryBoss.mergeInventoryReport(serialize(inventoryReport)); assert results != null; assert checkIgnoredTypes(results) : "nothing should have been ignored in this test"; assertNotNull(results.getPlatformSyncInfo()); assertNotNull(results.getPlatformSyncInfo().getTopLevelServerIds()); assertTrue(!results.getPlatformSyncInfo().getTopLevelServerIds().isEmpty()); Integer resourceId = results.getPlatformSyncInfo().getTopLevelServerIds().iterator().next(); Collection<ResourceSyncInfo> syncInfos = discoveryBoss.getResourceSyncInfo(resourceId); assert syncInfos != null; assert !syncInfos.isEmpty(); Resource resource1 = discoveryBoss.manuallyAddResource(subjectManager.getOverlord(), serviceType2.getId(), resourceId, new Configuration()); try { Resource resource2 = discoveryBoss.manuallyAddResource(subjectManager.getOverlord(), serviceType2.getId(), resourceId, new Configuration()); fail("Manually adding a singleton that already existed succeeded: " + resource2); } catch (EJBException e) { assertEquals(String.valueOf(e.getCause()), RuntimeException.class, e.getCause().getClass()); assertTrue(String.valueOf(e.getCause()), e.getCause().getMessage().contains("singleton")); } }