List of usage examples for javax.ejb TransactionAttributeType REQUIRED
TransactionAttributeType REQUIRED
To view the source code for javax.ejb TransactionAttributeType REQUIRED.
Click Source Link
From source file:com.flexive.ejb.beans.search.SearchEngineBean.java
/** * {@inheritDoc}/*from ww w. ja va 2 s .c om*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public FxResultSet search(String query) throws FxApplicationException { return search(query, 0, Integer.MAX_VALUE, null); }
From source file:com.sfs.ucm.security.Authenticator.java
/** * configure the authenticated user// w ww. j ava 2 s . co m * * @return AuthUser */ @TransactionAttribute(TransactionAttributeType.REQUIRED) private AuthUser configure(final String username, final HttpServletRequest request) { // find or persist user AuthUser authUser = this.authUserService.findUserByName(username); if (authUser == null) { // persist the user List<AuthUser> authUsers = authUserService.findAllAuthUsers(); authUser = new AuthUser(ModelUtils.getNextIdentifier(authUsers), username, username); this.authUserService.store(authUser); } // put userid in session scope context request.getSession().setAttribute("USERID", username); return authUser; }
From source file:com.redhat.winddrop.mdb.WindupExecutionQueueMDB.java
@TransactionAttribute(TransactionAttributeType.REQUIRED) public void buildAndUploadReport(String hashValue, String submitter, String packages) { LOG.info(">>> buildAndUploadReport (hashValue=" + hashValue + ",packages=" + packages + ")"); List<File> filesToDelete = new ArrayList<File>(); try {//from ww w . j av a 2 s . co m com.redhat.winddrop.model.File storedBinaryFile = fileRepository.findByHashValue(hashValue); String windupOutputDirectoryName = FileUtil.WINDDROP_TMP_DIR + hashValue + "_out" + FileUtil.FILE_SEPARATOR; File windupOutputDirectory = new File(windupOutputDirectoryName); windupOutputDirectory.mkdir(); filesToDelete.add(windupOutputDirectory); String windupInputDirectoryName = FileUtil.WINDDROP_TMP_DIR + hashValue + "_in" + FileUtil.FILE_SEPARATOR; File windupInputDirectory = new File(windupInputDirectoryName); windupInputDirectory.mkdir(); filesToDelete.add(windupInputDirectory); File windupInputFile = new File(windupInputDirectoryName + storedBinaryFile.getUploadedFileName()); // Copying the uploaded file and use it as input for windup. FileUtil.copy(new File(StringUtils.trim(storedBinaryFile.getStorageFileName())), windupInputFile); filesToDelete.add(windupInputFile); // Execute windup executeWindup(packages, windupInputFile, windupOutputDirectory); // Zip the resulting report String zippedReportFileName = storedBinaryFile.getUploadedFileName() + FileUtil.REPORT_EXTENSION; File zippedReport = new File(windupInputDirectoryName + zippedReportFileName); filesToDelete.add(zippedReport); LOG.info("[" + hashValue + "] Zipping the created report ..."); FileUtil.zip(windupOutputDirectory, zippedReport); // Upload the result LOG.info("[" + hashValue + "] Storing report ..."); fileRepository.removeReportRequest(hashValue); hashValue = FileUtil.storeFile(zippedReport, zippedReportFileName, fileRepository, submitter, packages, true, true); LOG.info("[" + hashValue + "] Execution successfull ... wget http://localhost:8080/winddrop/rest/dl/file/" + hashValue); } catch (Throwable t) { t.printStackTrace(); } finally { // Cleanup LOG.info("[" + hashValue + "] Cleaning temporary files ..."); for (File file : filesToDelete) { if (file.exists()) { if (file.isDirectory()) { try { FileUtils.deleteDirectory(file); } catch (IOException e) { } } else { file.delete(); } } } } LOG.info("<<< buildAndUploadReport"); }
From source file:com.flexive.ejb.beans.workflow.WorkflowEngineBean.java
/** * {@inheritDoc}/*from w w w. j a va 2s.c o m*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void remove(long workflowId) throws FxApplicationException { UserTicket ticket = FxContext.getUserTicket(); // Permission checks FxPermissionUtils.checkRole(ticket, Role.WorkflowManagement); // Do work... Connection con = null; Statement stmt = null; String sql = null; boolean success = false; try { // Obtain a database connection con = Database.getDbConnection(); // First delete all steps within the workflow .. stepEngine.removeSteps(workflowId); // .. then delete the workflow itself stmt = con.createStatement(); sql = "DELETE FROM " + TBL_WORKFLOW + " WHERE ID=" + workflowId; int count = stmt.executeUpdate(sql); // Check if the delete succeeded if (count == 0) { throw new FxNotFoundException(LOG, "ex.workflow.notFound", workflowId); } success = true; } catch (SQLException exc) { if (StorageManager.isForeignKeyViolation(exc)) throw new FxRemoveException("ex.workflow.delete.inUse", CacheAdmin.getEnvironment().getWorkflow(workflowId).getName(), workflowId); throw new FxRemoveException(LOG, "ex.workflow.delete", exc, workflowId, exc.getMessage()); } finally { Database.closeObjects(WorkflowEngineBean.class, con, stmt); if (!success) { EJBUtils.rollback(ctx); } else { StructureLoader.reloadWorkflows(FxContext.get().getDivisionId()); } } }
From source file:gov.medicaid.screening.dao.impl.OIGDAOBean.java
/** * Searches for excluded providers.//from ww w.j a va 2s . c o m * * @param criteria the search criteria * @return the matched results * @throws ParsingException if any parsing errors are encountered * @throws ServiceException for any other exceptions encountered */ @TransactionAttribute(TransactionAttributeType.REQUIRED) public SearchResult<ProviderProfile> search(OIGSearchCriteria criteria) throws ParsingException, ServiceException { String signature = "OIGDataAccessImpl#search"; LogUtil.traceEntry(getLog(), signature, new String[] { "criteria" }, new Object[] { criteria }); if (criteria == null || (Util.isBlank(criteria.getLastName()) && Util.isBlank(criteria.getFirstName()) && Util.isBlank(criteria.getBusinessName()))) { throw new ServiceException(ErrorCode.MITA10005.getDesc()); } validateSortOptions(criteria, SORT_COLUMNS); try { SearchResult<ProviderProfile> allResults = getAllResults(criteria); SearchResult<ProviderProfile> results = trimResults(allResults, criteria.getPageSize(), criteria.getPageNumber(), SORT_COLUMNS.get(criteria.getSortColumn()), criteria.getSortOrder()); logSearchEntry(criteria); return results; } catch (ClientProtocolException e) { LogUtil.traceError(getLog(), signature, e); throw new ServiceException(ErrorCode.MITA50001.getDesc(), e); } catch (URISyntaxException e) { LogUtil.traceError(getLog(), signature, e); throw new ServiceException(ErrorCode.MITA50001.getDesc(), e); } catch (IOException e) { LogUtil.traceError(getLog(), signature, e); throw new ServiceException(ErrorCode.MITA50001.getDesc(), e); } catch (ParseException e) { LogUtil.traceError(getLog(), signature, e); throw new ServiceException(ErrorCode.MITA50001.getDesc(), e); } }
From source file:com.flexive.ejb.beans.search.SearchEngineBean.java
/** * {@inheritDoc}/*www . ja v a2 s.com*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public FxResultSet search(String query, int startIndex, int fetchRows, FxSQLSearchParams params) throws FxApplicationException { return search(query, startIndex, fetchRows, params, AdminResultLocations.DEFAULT, ResultViewType.LIST); }
From source file:be.fedict.trust.service.dao.bean.CertificateAuthorityDAOBean.java
@TransactionAttribute(TransactionAttributeType.REQUIRED) public RevokedCertificateEntity addRevokedCertificate(String issuerName, BigInteger serialNumber, Date revocationDate, BigInteger crlNumber) { RevokedCertificateEntity revokedCertificate = new RevokedCertificateEntity(issuerName, serialNumber, revocationDate, crlNumber);/* w ww.j a va 2 s.c o m*/ this.entityManager.persist(revokedCertificate); return revokedCertificate; }
From source file:gov.medicaid.screening.dao.impl.SocialWorkLicenseDAOBean.java
/** * This method gets the applicable licenses that meet the search criteria, which only focuses on the name of the * licensee. If none available, the search result will be empty.. * * @param criteria the search criteria/* w w w .j a v a 2 s . c om*/ * @return the search result with the applicable providers * @throws IllegalArgumentException if criteria is null * @throws IllegalArgumentException if criteria.pageNumber < 0 * @throws IllegalArgumentException if criteria.pageSize < 1 unless criteria.pageNumber <= 0 * @throws ServiceException If an error occurs while performing the operation */ @TransactionAttribute(TransactionAttributeType.REQUIRED) public SearchResult<License> searchByName(SocialWorkLicenseSearchByNameCriteria criteria) throws ServiceException { String signature = "SocialWorkLicenseDAOBean#searchByName"; LogUtil.traceEntry(getLog(), signature, new String[] { "criteria" }, new Object[] { criteria }); if (criteria == null) { throw new IllegalArgumentException(ErrorCode.MITA10005.getDesc()); } if (criteria.getPageNumber() < 0 || (criteria.getPageNumber() > 0 && criteria.getPageSize() < 0)) { throw new IllegalArgumentException(ErrorCode.MITA10027.getDesc()); } if (Util.isBlank(criteria.getLastName()) && Util.isBlank(criteria.getFirstName())) { throw new IllegalArgumentException(ErrorCode.MITA10022.getDesc()); } return LogUtil.traceExit(getLog(), signature, doSearch(criteria)); }
From source file:com.flexive.ejb.beans.workflow.StepEngineBean.java
/** * {@inheritDoc}/* w ww . j a v a 2s . c o m*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public long createStep(Step step) throws FxApplicationException { UserTicket ticket = FxContext.getUserTicket(); // Security checks FxPermissionUtils.checkRole(ticket, Role.WorkflowManagement); // Create the new step Statement stmt = null; String sql; Connection con = null; boolean success = false; try { // Obtain a database connection con = Database.getDbConnection(); // Create any needed unique target step try { StepDefinition def; def = CacheAdmin.getEnvironment().getStepDefinition(step.getStepDefinitionId()); if (def.getUniqueTargetId() != -1) { createStep(new Step(-1, def.getUniqueTargetId(), step.getWorkflowId(), step.getAclId())); } } catch (FxLoadException exc) { throw new FxCreateException(LOG, "ex.step.create.uniqueTargets", exc, exc.getMessage()); } catch (FxNotFoundException exc) { throw new FxCreateException("ex.stepdefinition.load.notFound", step.getStepDefinitionId()); } //check if that step already exists long newStepId; stmt = con.createStatement(); sql = "SELECT ID FROM " + TBL_WORKFLOW_STEP + " WHERE STEPDEF=" + step.getStepDefinitionId() + " AND WORKFLOW=" + step.getWorkflowId(); ResultSet rs = stmt.executeQuery(sql); if (rs != null && rs.next()) { // return existing step ID as "new step ID" newStepId = rs.getLong(1); } else { // Create the step newStepId = seq.getId(FxSystemSequencer.STEP); // get maximum position sql = "SELECT MAX(pos) FROM " + TBL_WORKFLOW_STEP + " WHERE workflow=" + step.getWorkflowId(); ResultSet rs2 = stmt.executeQuery(sql); final int newPos; if (rs2.next()) { newPos = rs2.getInt(1) + 1; // 1-based } else { newPos = 1; // should not happen } sql = "INSERT INTO " + TBL_WORKFLOW_STEP + " (ID, STEPDEF, WORKFLOW, ACL, POS) VALUES (" + newStepId + "," + step.getStepDefinitionId() + "," + step.getWorkflowId() + "," + step.getAclId() + ", " + newPos + ")"; stmt.executeUpdate(sql); } // Refresh all UserTicket that are affected. // Do NOT use refreshHavingWorkflow since this function adds a workflow to tickets, so this function would // have no effect. // TODO //UserTicketImpl.refreshHavingACL(ACLId); success = true; // Return the new id return newStepId; } catch (SQLException exc) { throw new FxCreateException(LOG, "ex.step.create", exc, exc.getMessage()); } finally { Database.closeObjects(StepEngineBean.class, con, stmt); if (!success) { EJBUtils.rollback(ctx); } else { StructureLoader.reloadWorkflows(FxContext.get().getDivisionId()); } } }
From source file:com.sfs.ucm.controller.HelpContentAction.java
/** * save action//from w w w.jav a 2s . c om * * @throws UCMException */ @Log @TransactionAttribute(TransactionAttributeType.REQUIRED) public void save() throws UCMException { try { if (validate()) { if (helpItem.getId() == null) { this.helpItems.add(this.helpItem); } em.persist(helpItem); // fire help change event helpEventSrc.fire(this.helpItem); // queue message this.logger.info("Saved {}", this.helpItem.getKeyword()); facesContextMessage.infoMessage("messages", "{0} saved successfully", this.helpItem.getKeyword()); loadList(); } } catch (Exception e) { logger.error("Error occurred saving Help Content. {}", e.getMessage()); throw new UCMException(e); } }