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.structure.TypeEngineBean.java
/** * {@inheritDoc}/* w w w .jav a 2 s . com*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public long getInstanceCount(long typeId) { Connection con = null; long rc = -1; try { con = Database.getDbConnection(); rc = getInstanceCount(con, typeId); } catch (SQLException e) { //noinspection ThrowableInstanceNeverThrown throw new FxApplicationException(LOG, e, "ex.db.sqlError", e.getMessage()).asRuntimeException(); } finally { Database.closeObjects(TypeEngineBean.class, con, null); } return rc; }
From source file:com.flexive.ejb.beans.PhraseEngineBean.java
/** * {@inheritDoc}//from w ww .j av a 2 s. c o m */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public long savePhrase(String phraseKey, FxString value, Object tag, long mandator) throws FxNoAccessException { return savePhrase(FxPhraseCategorySelection.CATEGORY_DEFAULT, phraseKey, value, null, tag, mandator); }
From source file:com.flexive.ejb.beans.configuration.GlobalConfigurationEngineBean.java
/** * {@inheritDoc}/* www. j a v a2 s. c om*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public DivisionData[] getDivisions() throws FxApplicationException { final long timestamp = getTimestamp(); if (divisions.isEmpty() || divisionsTimestamp.get() < timestamp) { synchronized (divisions) { if (divisions.isEmpty()) { divisionsTimestamp.set(timestamp); final int[] divisionIds = getDivisionIds(); final List<DivisionData> divisionList = new ArrayList<DivisionData>(divisionIds.length); for (int divisionId : divisionIds) { try { divisionList.add(getDivisionData(divisionId)); } catch (Exception e) { LOG.error("Invalid division data (ignored): " + e.getMessage()); } } divisions.addAll(divisionList); } } } return divisions.toArray(new DivisionData[divisions.size()]); }
From source file:io.hops.hopsworks.api.pythonDeps.PythonDepsService.java
@POST @Produces(MediaType.APPLICATION_JSON)/*from w w w . j a v a2 s. c om*/ @Path("/install") @AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST }) @TransactionAttribute(TransactionAttributeType.REQUIRED) public Response install(PythonDepJson library) throws ServiceException, GenericException { if (settings.getPreinstalledPythonLibraryNames().contains(library.getLib())) { throw new ServiceException(RESTCodes.ServiceErrorCode.ANACONDA_DEP_INSTALL_FORBIDDEN, Level.INFO, "library: " + library.getLib()); } if (project.getName().startsWith("demo_tensorflow")) { List<OpStatus> opStatuses = pythonDepsFacade.opStatus(project); int counter = 0; while ((opStatuses != null && !opStatuses.isEmpty()) && counter < 10) { try { Thread.sleep(1000); } catch (InterruptedException ex) { logger.log(Level.SEVERE, "Error enabled anaconda for demo project", ex); } opStatuses = pythonDepsFacade.opStatus(project); counter++; } } pythonDepsFacade.addLibrary(project, PythonDepsFacade.CondaInstallType.valueOf(library.getInstallType()), PythonDepsFacade.MachineType.valueOf(library.getMachineType()), library.getChannelUrl(), library.getLib(), library.getVersion()); return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).build(); }
From source file:com.flexive.ejb.beans.PhraseEngineBean.java
/** * {@inheritDoc}/*from w w w. ja v a 2 s.c o m*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public long savePhrase(int category, String phraseKey, FxString value, Object tag, long mandator) throws FxNoAccessException { return savePhrase(category, phraseKey, value, null, tag, mandator); }
From source file:com.flexive.ejb.beans.workflow.StepDefinitionEngineBean.java
/** * {@inheritDoc}//from w w w .j a v a2s . co m */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void remove(long id) throws FxApplicationException { final UserTicket ticket = FxContext.getUserTicket(); // Cannot delete basis step if (id == StepDefinition.LIVE_STEP_ID || id == StepDefinition.EDIT_STEP_ID) { throw new FxNoAccessException("ex.stepdefinition.delete.system"); } // Security checks FxPermissionUtils.checkRole(ticket, Role.WorkflowManagement); // Check existance getEnvironment().getStepDefinition(id); // Now try to delete the stepDefinition Connection con = null; Statement stmt = null; String sql; boolean success = false; try { // Obtain a database connection con = Database.getDbConnection(); // Read all stepDefinitions from the database stmt = con.createStatement(); sql = "DELETE FROM " + TBL_WORKFLOW_STEPDEFINITION + ML + " WHERE ID=" + id; stmt.executeUpdate(sql); sql = "SELECT COUNT(*) FROM " + TBL_WORKFLOW_STEPDEFINITION + " WHERE UNIQUE_TARGET=" + id; ResultSet rs = stmt.executeQuery(sql); rs.next(); if (rs.getInt(1) > 0) { FxRemoveException dbe = new FxRemoveException("ex.stepdefinition.delete.used"); LOG.error(dbe); throw dbe; } sql = "DELETE FROM " + TBL_WORKFLOW_STEPDEFINITION + " WHERE ID=" + id; if (stmt.executeUpdate(sql) == 0) { FxEntryInUseException eiu = new FxEntryInUseException("ex.stepdefinition.load.notFound"); if (LOG.isInfoEnabled()) LOG.info(eiu); throw eiu; } success = true; } catch (SQLException exc) { // TODO add Database.childRecordsExistViolation /*if (Database.childRecordsExistViolation(exc)) { FxDeleteException dbe = new FxDeleteException("The StepDefinition is in use", exc); LOG.error(dbe); throw dbe; } else {*/ throw new FxRemoveException(LOG, "ex.stepdefinition.delete", exc); //} } finally { Database.closeObjects(StepDefinitionEngineBean.class, con, stmt); if (!success) { EJBUtils.rollback(ctx); } else { StructureLoader.reloadWorkflows(FxContext.get().getDivisionId()); } } }
From source file:com.flexive.ejb.beans.structure.TypeEngineBean.java
/** * {@inheritDoc}/*from w w w.j av a 2 s . c om*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void flatten(String storage, long typeId) throws FxApplicationException { flatten(storage, typeId, null); }
From source file:com.flexive.ejb.beans.PhraseEngineBean.java
/** * {@inheritDoc}//from w ww . ja v a2 s . c om */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public long savePhrase(String phraseKey, FxString value, FxPhraseSearchValueConverter converter, Object tag, long mandator) throws FxNoAccessException { return savePhrase(FxPhraseCategorySelection.CATEGORY_DEFAULT, phraseKey, value, converter, tag, mandator); }
From source file:com.flexive.ejb.beans.structure.TypeEngineBean.java
/** * {@inheritDoc}//from w ww .jav a 2 s . c om */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void flatten(String storage, long typeId, FlattenOptions options) throws FxApplicationException { Connection con = null; try { con = Database.getDbConnection(); FxFlatStorageManager.getInstance().flattenType(con, storage, CacheAdmin.getEnvironment().getType(typeId), options); StructureLoader.reload(con); } catch (FxApplicationException e) { EJBUtils.rollback(ctx); throw e; } catch (Exception e) { EJBUtils.rollback(ctx); throw new FxUpdateException(e); } finally { Database.closeObjects(TypeEngineBean.class, con, null); } }
From source file:com.flexive.ejb.beans.ScriptingEngineBean.java
/** * {@inheritDoc}/*from ww w. ja va 2s . co m*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void updateScriptCode(long scriptId, String code) throws FxApplicationException { FxScriptInfo si = CacheAdmin.getEnvironment().getScript(scriptId); updateScriptInfo(new FxScriptInfoEdit(si.getId(), si.getEvent(), si.getName(), si.getDescription(), code, si.isActive(), si.isCached())); }